Tracking search terms for adword campaign

Posted by Sascha 

Advanced
Sascha [ # ]
July 28, 2011 02:28PM
Hi,

I'm currently setting up Piwik but I have a problem getting the data I need about my adword campaigns:

I am aware that I can manually set up campaigns and that I can dynamically insert the keyword which has been clicked by using {keyword}.

The problem is: I don't need the keyword but the actual search term. Let's say I would have booked "piwik" with broad match in adwords and someone is looking for "piwik demo". My ad will be shown due to broad match but instead of telling me in Piwik that the user originally searched for "piwik demo" I will just get the keyword information - "piwik".

So instead of getting the Google valuetracker information about the keyword I would need to analyse the referrer just as it's done for organic traffic but still connect this to a campaign I have set up manually (just as the dev team intends to do completely automatically with #517) to differentiate organic and paid search terms.

Any suggestions to enable this?

Thanks a lot,
Sascha
matt [ # ]
July 30, 2011 04:18PM
Maybe there is an adwords special {tag} for the keyword you are looking for?




Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. I'm on twitter & on github


Sascha [ # ]
August 01, 2011 01:34PM
As far as I can tell Google only forwards the booked keyword which might be a broad match term but not the search term which actually caused the ad to appear.

The only way to get the search term is by analysing the referrer. What's really strange is that Piwik can actually analyse this information. In that case however all search terms are put together with organic search terms. To differentiate organic from paid search I have to set up a campaign. As soon as I do this the referrer information seems to be discarded.
murry [ # ]
October 05, 2011 12:44PM
I had the same problem and implemented a quick and dirty fix. Now if the campaign keywords are empty, piwik analyzes the referer url and uses the original search strings from the referer as campaign keywords.

In "core/Tracker/Visit.php" I changed the function "detectRefererCampaign" in class "Piwik_Tracker_Visit_Referer" to this:

protected function detectRefererCampaign()
	{
		if(isset($this->currentUrlParse['query']))
		{
			$campaignParameters = Piwik_Common::getCampaignParameters();

			$campaignNames = $campaignParameters[0];
			foreach($campaignNames as $campaignNameParameter)
			{
				$campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignNameParameter);
				if( !empty($campaignName))
				{
					break;
				}
			}

			if(!empty($campaignName))
			{
				$this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
				$this->nameRefererAnalyzed = $campaignName;
				$campaignKeywords = $campaignParameters[1];

				$i = 0; //mychanges
				$num_elements = count($campaignKeywords);//mychanges
				foreach($campaignKeywords as $campaignKeywordParameter)
				{
					$i++;
					$campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordParameter);
					if( !empty($campaignKeyword))
					{
						$this->keywordRefererAnalyzed = $campaignKeyword;
						break;
					}
					elseif ($i == $num_elements) {//mychanges
						$searchEngineInformation = Piwik_Common::extractSearchEngineInformationFromUrl($this->refererUrl);//mychanges
						Piwik_PostEvent('Tracker.detectRefererSearchEngine', $searchEngineInformation, $this->refererUrl);//mychanges
						if($searchEngineInformation !== false){//mychanges
								$this->keywordRefererAnalyzed = $searchEngineInformation['keywords'];//mychanges
								break;//mychanges
						}//mychanges
					}//mychanges
				}

				return true;
			}
		}
		return false;
	}

It seems to do what I want - however I haven't used Piwik for long and am not that familiar with the source code, so there might be some side effects I am not aware of.
Sascha [ # ]
October 05, 2011 01:30PM
Hi murry,

thanks a lot - this could solve my problem!

Regards,
Sascha
murry [ # ]
October 05, 2011 02:15PM
Beware however that this is a change to a core file.

It would probably be better to make a plugin, but I haven't had the time to figure out yet how those work yet.
matt [ # ]
October 08, 2011 07:41AM
Murry, thanks for the patch. I cross linked it from the related ticket about better campaign tracking: [dev.piwik.org]

You are probably on a very good track. if you can, please read the ticket and post your patch there if it's the solution (or partial) to the problem and solutions exposed there? cheers




Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. I'm on twitter & on github


wilko [ # ]
October 19, 2011 10:54AM
Hi murry,

Any luck with a plugin? I've changed the core file and it is working well but like you would be more comfortable with a plugin (plus don't want to have to remember to change it again on update) tongue sticking out smiley

I'm looking into plugin development now but if you've already started, I don't want to duplicate your work...

Matt, what are the chances of this patch making it into the next release (and of piwik distinguishing between adwords referred traffic and normal search traffic, even when campaign parameters also exist in the querystring)?

Cheers,
Wilko



Edited 1 time(s). Last edit at 10/19/2011 11:07AM by wilko.
matt [ # ]
October 19, 2011 11:04AM
wilko, I would like to fix the ticket. IT would really help if you were able to post a comment on the ticket, explaining what your patch does, how to test it (example adwords URLs, etc.), what exact problem it fixes (ie. does it fix all problems mentionned in the ticket?), and commit a patch as explained in: [piwik.org]

Then I promise I will commit it asap smiling smiley




Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. I'm on twitter & on github


wilko [ # ]
October 19, 2011 11:06AM
no probs - i'll get on it smiling smiley (it's murry's patch btw)



Edited 1 time(s). Last edit at 10/19/2011 11:07AM by wilko.
beat [ # ]
September 23, 2012 12:04AM
Hi wiljo,
Any hope to get this as a documented patch on the tracker, so it could be in piwik anytime soon ?

Has been almost a year since last activity winking smiley

Best regards,
matt [ # ]
December 14, 2012 09:41AM
I've updated the ticket and increased priority in order to commit this change : [dev.piwik.org]




Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. I'm on twitter & on github


Sorry, only registered users may post in this forum.

Click here to login

Free Forum support is provided by the Piwik Community. If you require any urgent or professional help, contact Piwik Professional Services team!