I want to add tokens to my facebook ads. For example, keyword=woman
I am sending the ad to a site on my server with a .php redirect: www.mysite.com/redirect.php
This page has a php redirect script with my tracking link in it.
How do I go about setting this up so that my FB ad keyword parameter gets inserted into my tracking link on redirect and passes to my tracker?
This is very simple passing of querystrings. You use the $_GET['something'] function of PHP.
There is some example scripting for this in my FB tutorial - http://stmforum.com/forum/showthread...l=1#post147270 - definitely copy/paste the code into a syntax-highlighting program like Dreamweaver to make sense of it.
In short, to get the querystring data:
$_GET['keyword'];
So, you can use use $_GET['keyword'] in your affiliate link to insert "woman". You need to be careful with syntax and separating variables from static text. An example:
header('Location: http://myaffurl.com/something?a=1234&c=5678&s1='.$_GET['keyword'].'&s2=somethingelse');
argh i just tried it and couldn't get it to work.
<?php
header( 'Location: http://mytrackerlink.base.php?keyword='.$_GET['keyword'].'&ad=EDIT' ) ;
?>
At first I screwed up the syntax and the link didn't work. Now the link works but no parameter is getting passed to my tracker...
Make sure the URL is being built correctly.
You should be encoding the keyword so the URL doesn't break on special chars/spaces.
<?php $kw=urlencode($_GET['keyword']); $buildurl= "http://mytrackerlink.base.php?keyword=$kw&ad=EDIT"; echo "Build URL: $buildurl"; // header( 'Location: '.$buildurl); ?>
Thanks a lot I got it working!