Wordpress: query string GET and use on pages?

5 replies
Hey Warriors!

I'm actually wondering if there is a NON-programming solution to this.

I like to track all my ad campaigns, sometimes with more than one variable.

Example: myawesomesite.com?CampaignID=Facebook&SubCampaignI D=ad03a

I normally just create all my webpages from scratch, and in PHP its a simple matter of grabbing the variables from the query string, then just passing those arguments on through my site whenever I want to link to another page.

example link: myawesomesite.com/about.php?CampaignID=<?= $CampaignID ?>&SubCampaignID=<?= $SubCampaignID ?>

The idea is to ultimately capture this when the user completes a call to action of some sort, either placing an order or opting in to a list, etc., and then storing this info in my database.

So, an opt-in form on my site would have a hidden field something like:
<input type="hidden" name="CampaignID" value="<?= $CampaignID ?>" />

But, I'm just starting out with Wordpress, and am not sure if there is some kind of "built in" method for grabbing the query string variables and then "displaying" them on the page. For me, I'll just be using the variables in links or hidden fields on a form, but you get the idea.

Any advice on built in WP funtions to handle this folks? A simple plugin?

If you aren't using this method, how are all you Wordpress whiz's tracking your campaigns?

I spent quite a bit of time googling, but came up short. Could be I am just not thinking the right keywords to be searching on though...

Thanks!

Matt
#pages #query #string #wordpress
  • Profile picture of the author dwoods
    Yes you can do this easily by adding the same code you use for your raw php verison to the theme files in your wordpress installation.
    {{ DiscussionBoard.errors[7135407].message }}
  • Profile picture of the author boilingstocks
    Add this code in your header.php file and it'll do
    {{ DiscussionBoard.errors[7135418].message }}
    • Profile picture of the author MktgGuy
      Thanks folks.

      I thought it might be something like that, but was hoping to avoid modifying any of the theme files. Not sure, but I think potential future theme updates would overwrite that. (Not a huge deal, as its just a few lines of code, but still.)

      Thanks again.

      Matt
      {{ DiscussionBoard.errors[7135438].message }}
  • Profile picture of the author boilingstocks
    Just make use of Wordpress - child themes feature so that future updates don't erase your code and everything works fine !
    {{ DiscussionBoard.errors[7135466].message }}
    • Profile picture of the author MktgGuy
      Wordpress - child themes feature
      D'oh! I totally forgot about this.

      Wordpress n00b here.

      Thanks a ton.

      Matt
      {{ DiscussionBoard.errors[7135519].message }}

Trending Topics