I am trying to add event tracking to a product that is being translated to html cross-domain...
The file is located server-side and written in PHP. The JSON snippet that I need to append the GA event to is as follows:
"products": [
{
"title": "product",
"description": "description",
"thumbnail": "http://myurl.com/picture.jpg",
"price": "£1.99",
"url": "http://link.com"
},]
Now, reading up a little bit on this on this article has given me a bit of insight: Using google analytics to track hits on an XML web service
Would it be a matter of something as simple as this?
<?php
//Initilize GA Tracker
$tracker = new GoogleAnalytics\Tracker('UA-12345678-9', 'example.com');
?>
"products": [
{
"title": "product",
"description": "description",
"thumbnail": "http://myurl.com/picture.jpg",
"price": "£1.99",
"url": "http://link.com"
},$ga->setEvent("Category", "Action", "Label", "Value");]
Sure, look at mit Github Project
https://github.com/ins0/google-measurement-php-client
it is a PHP client library to communicate with Google Analytics from server-side. otherwise you can use other great repositorys, look here