Not Tracking Initial Visit's Google's utm_campaign Flag


#1

I’ve been running into a problem where Piwik isn’t correctly getting the campaign information when coming in from a PPC link with utm_campaign set in the URL.

The user loads the page and we adds four things to run after Piwik’s JS loads. It runs setCampaignNameKey, trackPageView, and enableLinkTracking, followed by a custom event that sets some hidden inputs. These inputs get submitted in our web forms when they submit their information, being used to post to Piwik later on in the sales cycle.

Our issue is that the custom event only sometimes sets the hidden inputs correctly. The Piwik events seem to be firing every time, however the calls this.getVisitorId(), this.getAttributionCampaignName(), this.getAttributionCampaignKeyword(), and this.getAttributionReferrerUrl() seem to be returning blank values, usually on the initial page load.

My test usually go like this. I load a virtual machine and come to our website using a PPC link. The utm_campaign is present and formatted correctly in the query string. I check the hidden inputs and they are blank. I then reload the page (with utm_campagn still set in the URL), and once loaded the hidden inputs will be set correctly on the page.

Our current Piwik code is set up like this:
https://gist.github.com/droppedoncaprica/307df8196e95365dda29

Most of our pages are static HTML pages, being served by Apache. We have a virtualhost that takes all requests from /analytics/ and gives it to our Piwik installation.

Any ideas on why the utm_campaign isn’t being pulled from the URL every time?


(Matthieu Aubry) #2

Hi there,

Thanks for the report. It could be a bug or missing feature in Piwik.

however the calls this.getVisitorId(), this.getAttributionCampaignName(), this.getAttributionCampaignKeyword(), and this.getAttributionReferrerUrl() seem to be returning blank values, usually on the initial page load.

How this works: during the trackPageView() call, the referrer information is detected (from URL, referrer) and stored in the cookie.
When you call getAttributionCampaignName() it will try to read the value from the cookie.

Maybe in your case do you think the events could fire before the trackPageView() was executed?