I am using:
https://developers.google.com/analytics/devguides/collection/protocol/v1/
for server side tracking.
This is the set-up:
- Google analytics account.
- Google adwords account.
- Adwords account is linked to the analytics account.
I create an ad in adwords, the user clicks the ads, the user visits the third party website, the third party website make a https POST request with the visitor gclid from adwords. This is stored in a mysql database.
In the google adwords account I have an event for conversion created. (Using the offline tracking conversion works, but the only reason why I would prefer to use measurement protocol is because the offline tracking only accepts the conversions after 90 minutes. )
And I send the page views and conversion in this way:
/**
* @param $gclid
* @param $clientId
* @return \TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse
*/
private function sendPageView($gclid, $clientId){
$this->analytics
->setProtocolVersion(1)
->setTrackingId(self::GLOBAL_TRACKING_ID)
->setGoogleAdwordsId($gclid)
->setAnonymizeIp(true)
->setClientId($clientId);
return $this->analytics->sendPageview();
}
/**
* @param $gclid
* @param $clientId
* @return \TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse
*/
private function sendConversion($gclid, $clientId, $url){
$this->analytics
->setProtocolVersion(1)
->setTrackingId(self::GLOBAL_TRACKING_ID)
->setGoogleAdwordsId($gclid)
->setAnonymizeIp(true)
->setClientId($clientId)
->setEventAction('s2s')
->setEventCategory('Lead')
;
return $this->analytics->sendEvent();
}
Response:
object(TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse)#1008 (3) {
["httpStatusCode":protected]=>
int(200)
["requestUrl":protected]=>
string(164) "https://ssl.google-analytics.com/collect?v=1&tid=UA-1XXXXX-1&gclid=EAIaIQobChMInvrxopLZ5gIVXXXXXXXXXXXXXXXXXXXX_BwE&aip=1&cid=1&ea=s2s&ec=Lead&t=event"
["responseBody":protected]=>
string(35) "GIF89a�����,D;"
}
So the response is 200, however the conversion is not recorded anywhere, and I am not sure if I should be sending any other parameter, or how to debug the issue.