Tracking kws from AdWords

Status
Not open for further replies.

Enigmabomb

New member
Feb 26, 2007
2,035
66
0
Than Franthithco
Hey Guys,

I have this script to try and figure out how people are getting to my page and via what keywords, but it doesn't seem to be working. I tested the regex, that works, but I think adwords is changing the referring URL? Is there a way I can make the URL I'm calling contain the keywords? I think I read about that in Adwords help?


Here is what I have to test:

<?php $url_array = parse_url($_SERVER['HTTP_REFERER']); $varmix = $url_array['query']; preg_match("/q=(.*?)&/",$varmix,$result); echo "<!-- ".$varmix." -->"; ?>


How am I fucking this up?

Thanks,

Josh
 


Since your using AdWords, have you considered using DKI (Dynamic Keyword Insertion)?

It seems like a much simpler solution personally... You could just assign the Target URL for your Ads to be http://mydomain.com/?keyword={KeyWord} and then on your LP just use a basic $keyword = $_GET['keyword'], etc.

Otherwise, maybe consider doing something like...

$queryStringExplode = explode('&', $url_array['query']);

foreach($queryStringExplode as $queryPiece) {
$queryPieceExplode = explode('=', $queryPiece);
$queryArray[$queryPieceExplode[0]] = $queryPieceExplode[1];
}

echo $queryArray['q'];

Its a few more lines and a little bit more BS, but seems to be a more solid approach to finding the keyword, also, if they do change the param name that has the query, you can swap out... $queryArray['q'] forwhatever the name of the new param is....
 
Status
Not open for further replies.