12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Jul 27, 2019

[Condition] URL Parameter

Sridhar Katakam

Update on April 15, 2020: Also added != operator.


This premium tutorial provides the steps to add a custom condition using which elements in Oxygen can be output based on the value of specific URL parameter like /?referrer=facebook.

Use Case

Let's say you want to output a section having for example, a welcome message on the front end only for users that visit your site from Facebook and you want to output another Section only for visitors that land on your Page after clicking through a link in Twitter.

To achieve this personalization, you could

  1. define "referrer" query variable in WordPress
  2. register a condition that returns true if the URL parameter matches with the one user enters in the condition
  3. set condition for your Oxygen sections i.e., enter facebook as the value of referrer URL parameter for the Facebook section and twitter as the value of referrer URL parameter for Twitter section.
  4. use referrer query variable in your URLs like example.com/?referrer=facebook and example.com/?referrer=twitter

Caveat

This does not work on the homepage due to a bug in WordPress.

Step 1

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Add "referrer" query variable

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right