Information:
I'm working on a phone-tracking project that uses the Google Analytics measurement protocol, that should do the following when finished:
I'm Using the library:
Everything is setup according to php-ga-measurement-protocol, and it seems to be working - i can add event/hit to a goal in Google Analytics, without any problems.
But the problems comes when i'm asking Google Adwords to import the data(goals) from Google Analytics - it doesnt add any conversions - it says every hit just comes from "Direct/non".
Code:
$analytics = new TheIconic\Tracking\GoogleAnalytics\Analytics(true);
$analytics->setProtocolVersion('1')
->setHitType('event')
->setTrackingId($sGoogleAnalyticID)
->setClientId($sClientID)
->setEventCategory('MyEventCategory')
->setEventAction('MyAction')
->setEventValue(1)
->sendEvent();
I figured it made sense, since i'm not adding the UTM data, so i tried setting the UTM data on the $analytics object as seen below:
$analytics = new TheIconic\Tracking\GoogleAnalytics\Analytics(true);
$analytics->setProtocolVersion('1')
->setHitType('event')
->setTrackingId($sGoogleAnalyticID)
->setClientId($sClientID)
->setEventCategory('MyEventCategory')
->setEventAction('MyAction')
->setEventValue(1)
->setCampaignName($sUtmCampaign) //&utm_campaign=[xxxxx] - para name value is taken from
->setCampaignSource($sUtmSource) //&utm_source=[xxxxx] - para name value is taken from
->setCampaignMedium($sUtmMedium) //&utm_medium=[xxxxx] - para name value is taken from
->setCampaignContent($sUtmContent) //&utm_content=[xxxxx] - para name value is taken from
->sendEvent();
The Questsions:
I would appreciate any help or if someone could point me in the right direction - i have used countless hours googling and trying stuff.
For the conversion hit to be assigned to a proper Google Ads campaign/keyword in a linked Google Analytics account it must belong to a session that starts with a pageview with a specified gclid=XXXXX
parameter in the URL. The value of gclid
is Google Ads click identifier and allows matching Analytics and Ads data. In case if your measurement protocol request is not aligned with the corresponding session the hit won't be recorded as a conversion in Google Ads.
You might want to store the gclid
serverside for each supposed conversion and include that in your measurement protocol location
parameter. However, this might result in the creation of redundant sessions and unpredictable discrepancies in reporting.
Consult Analytics docs on campaign attribution for further details.