How to put PHP tracking code on individual Wordpress Posts

4 replies
This PHP tracking code below is what I want to put on this ONE page on my site How Buy Silver Bullion

PHP Code:
<? 
    $referrer = urlencode($_SERVER['HTTP_REFERER']); 
    $referrer =  str_replace("http://","", $referrer);
    $referrer =  str_replace("https://","", $referrer);
    if(!$_GET['apflag']) header("Location: http://www.ourkangen.net/affiliateprophetscript/go.php?uid=1&cid=1&apflag=1&referrer=$referrer&".$_SERVER["QUERY_STRING"]);
    if(!$_COOKIE['apid']) setcookie("apid", $_GET['apid'], time()+300000000);
?>
I have no idea how to even do that but there must be a way. Please tell me what I need to do in order to successfully add that tracking code

Thanks!
#code #php #tracking #wordpress
  • Profile picture of the author cosmolito
    I was getting a blank screen on the submission process when trying to post the above post.

    I guess I pressed "submit post" 3 times which is why this post appears 3 times in a row.
    Signature
    My $money$ line 360-810-8062
    {{ DiscussionBoard.errors[4610445].message }}
  • Profile picture of the author AdWorkMedia
    The best place to put common code like this is on a page that is called throughout your website. The header.php and footer.php files are perfect examples of that. So you could place this is either of those files and you should be set.

    You can edit these files right from your WP admin. Just find the files under the Appearance tab.
    Signature


    AdWork Media » Global Affiliate Network & Content Locking Solutions

    Custom Platform, Flexible Lockers, Offers For Every Country
    {{ DiscussionBoard.errors[4614263].message }}
    • Profile picture of the author cosmolito
      ya but I need the tracking only for one specific page on my website and that sounds like a global solution
      Signature
      My $money$ line 360-810-8062
      {{ DiscussionBoard.errors[4614926].message }}
  • Profile picture of the author rufaswan
    From the look of it, it don't seems to be a tracking code, but a redirecting code. It is meant to redirect user to another page, as one of the line read " header("Location: http://somesite.com") "

    Normally, a tracking code is not PHP code, but a Javascript code (same as Google Analytics) or a single 1x1 pixel image (called tracking pixel). You don't have to edit any template files to insert them. Just edit your existing post and put the code there. That's all.

    - Rufas
    {{ DiscussionBoard.errors[4617803].message }}

Trending Topics