Google analytics not tracking enhanced ecommerce Data - google-analytics

i manage several hotels on analytics, actually have like 400, and we are updating the ecommerce data to enhanced ecommerce.
when i updated the scripts to e ecommerce on 100 hotels, no one was working, so i ran a test and i found that the isogram analytics code wasnt implemented, fixed that and now 70/100 hotels are getting ecommerce data.
idk if is matter of time to get the data on the last 30 hotels but here is the code, if anyone can see anything wrong, thanks.
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'viewcode', 'auto', {'allowLinker': true});
// Load the plugin.
ga('require', 'linker');
// Define which domains to autoLink.
ga('linker:autoLink',['websites']);
ga('send', 'pageview');
ga('require', 'ec');
ga('set', '&cu', 'MXN');
ga('ec:addProduct', {
'id': '{SkuCode}',
'name': '{ProductName}',
'category': '{Category}',
'price': '{UnitPrice}',
'quantity': {Quantity}
});
ga('ec:setAction', 'purchase', {
id: '{NoReservation}',
revenue: '{Total}',
tax: '{Tax}'
});
ga('send', 'event');
</script>

The analytics code that you are using it looks right, however in order to assure that analytics code is pushed from the all the hotels websites I recommend you to follow the following steps:
1) Check that hotels domains name are correctly in the "linker" parameter
2) Verify that those websites dont't have another GA analytics code that overwrite your code. In order to avoid conflicts I recommend you to rename the "ga" global object to "myga" or something like that. Example:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','myga');
myga('create', 'viewcode', 'auto', {'allowLinker': true});
// Load the plugin.
myga('require', 'linker');
// Define which domains to autoLink.
myga('linker:autoLink',['websites']);
myga('send', 'pageview');
...
You can check when a hotel is pushing events if you are using the GA Real-time in the GA dashboard.

Related

Google Analytics Page Speed Implementation

I am wondering how to implement correctly google analytics page speed measurements and how to change the sample size correctly:
As seen below in the code box we currently Google analytics including eCommerce running on our site. Now I would like to also increase the sample sizeof speed tracking (the percentage of pageviews used for speedtracking, usually 1%) to 100% on our staging system.
As far as I understood I can do that by following this instructions.
My question not is if I just add it to the existing create method in my analytics snippet or do I have to create another method below.
If I understood correctly I would now do this:
replace
ga('create', 'UA-XXXXXXX-1', 'ricomprostaging.it');
with
ga('create', 'UA-XXXXXXX-1', {'sampleRate': 5}, 'ricomprostaging.it');
Please advise if I am on the right track. I have placed the entire code of the current snippet below.
Thank you,
Fabian
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXX-1', 'ricomprostaging.it');
ga('send', 'pageview');
ga('send', 'pageview', 'search_query');
ga('require', 'ecommerce', 'ecommerce.js');
function trackEcommerce() {
this._addTrans = addTrans;
this._addItem = addItems;
this._trackTrans = trackTrans;
}
function addTrans(orderID,store,total,tax,shipping,city,state,country) {
ga('ecommerce:addTransaction', {
'id': orderID,
'affiliation': store,
'revenue': total,
'tax': tax,
'shipping': shipping,
'city': city,
'state': state,
'country': country
});
}
function addItems(orderID,sku,product,variation,price,qty) {
ga('ecommerce:addItem', {
'id': orderID,
'sku': sku,
'name': product,
'category': variation,
'price': price,
'quantity': qty
});
}
function trackTrans() {
ga('ecommerce:send');
}
var pageTracker = new trackEcommerce();
</script>
Yes you need to replace the create statement on all pages. However sampleRate is the wrong option: this option defines the sample rate for Google Analytics as a whole. For sampling speed, you want to use siteSpeedSampleRate. As for the code, I would use the following:
ga('create', 'UA-XXXXXXX-1', {
'siteSpeedSampleRate': 5,
'cookieDomain': 'ricomprostaging.it'
});

Anatlytics - Two trackingIDs, only one get events

we have two tracking codes on our site. On both codes we get tracking of visitors and stuff correct, but when it comes to events, only one is getting the event even tho' we're sending it to both codes.
This is the setup:
ga('create', 'UA-12345678-6', 'auto');
ga('create', 'UA-123456-4', 'auto', 'clientTracker');
ga('require', 'displayfeatures');
ga('clientTracker.require','displayfeatures');
ga('require', 'ecommerce', 'ecommerce.js');
ga('clientTracker.require','ecommerce','ecommerce.js');
ga('send', 'pageview');
ga('clientTracker.send', 'pageview');
and this is the event:
$("#desktopCheckout").on("click", function() {
ga('send', 'event', 'test', 'clickOnCheckout');
ga('clientTracker.send', 'event', 'test', 'clickOnCheckout');
});
The event is being sent to the regular tracking code, but not to the "clientTracker".
Are we doing something wrong here?
GA Debug extension and Tag assistant extension in Chrome both shows that the event is being sent, and I've checked the tracking ID so it is correct. Just somehow Google Analytics is not recieving this.

Is it possible to rename the IDs in Google Analytic's Enhanced Ecommerce?

What I'd like to do is change the names of certain fields for better tracking for my website. I don't have a tax, and organization doesn't ship anything. So I was wondering if I could change those fields to something else like shipping -> gifts, and track for any additional funds donated part of their initial donation, that would be awesome. I've tried googling this but there's so much information to sort through that so far I haven't found an answer.
Google's provided code
ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');
ga('set', '&cu', 'EUR'); // Set tracker currency to Euros
ga('ec:setAction', 'purchase', {
id: 'T12345',
affiliation: 'Google Store - Online',
revenue: '28.03',
tax: '2.14',
shipping: '4.00',
});
ga('send', 'pageview');
The code I'd like to use
<script>
var formatDollar = '[[S120:dc:giftAmount]]';
formatDollar.split(",").join("");
var dollarAmt = formatDollar.split(",").join("");
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y');
ga('require', 'ec');
ga('ec:setAction', 'purchase', {
id: '[[S120:dc:transactionID]]',
affiliation: '[[S120:dc:donationFormName]]',
revenue: dollarAmt,
category: '[[S120:dc:giftType]]',
currency: 'CAD'
gifts: '[[S120:dc:additionalGifts]]',
});
ga('ecommerce:send');
ga('send', 'pageview');
Would this work? (I know my UA code needs to be fixed I just forgot what the code was so i just put whatever).
I would test it, but right now the person in charge of all the GA stuff just left for the week, so I won't know if it works or not until they come back (no access to the GA account).
Thank you for your time.
You could change the name, but GA won't recognise those names and know what to do with them. If some parameters don't apply, like shipping, then you could simply leave them out; only id is required. Or if you want to include other parameters, then they would need to be done as custom dimensions:
ga('ec:setAction', 'purchase', {
id: '[[S120:dc:transactionID]]',
affiliation: '[[S120:dc:donationFormName]]',
revenue: dollarAmt,
category: '[[S120:dc:giftType]]',
currency: 'CAD',
dimension1: '[[S120:dc:additionalGifts]]',
});
where dimension1 is configured as a product-scoped custom dimension and contains the value for your gifts.

Universal Analytics cross domain tracking with multiple trackers

So i have Universal Analytics code with multiple trackers:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-xxxxxxxx-x', 'auto');
ga('create', 'UA-yyyyyyyy-y', 'auto', {'name': 'second'});
ga('send', 'pageview');
ga('second.send', 'pageview');
</script>
How do i create Cross Domain tracking since UA-yyyyyyyy-y profile is used to gather info from 2 separete domains. With one tracker it is pretty simple:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-yyyyyyyy-y', 'auto', {'allowLinker': true});
ga('linker:autoLink', ['other-domain.com'] );
ga('send', 'pageview');
</script>
But what do i do wen i have 2 trackers, how do i set up cross domain tracking for this Universal Analytics profile: UA-yyyyyyyy-y? If you answer my question you will also answer a part of this question:
http://stackoverflow.com/questions/20126897/google-analytics-cross-domain-tracking-with-multiple-trackers
In your example with just a single tracker, you're missing the call to require the linker plugin. Without that it won't work. Perhaps that is the source of your issue.
Regardless, in analytics.js you can call any method on any tracker by simply prefixing the method name with the tracker name. You'll notice your first example already does this in the line ga('second.send', 'pageview').
So, to implement auto-linking on both trackers you'd do something like this:
ga('create', 'UA-yyyyyyyy-y', 'auto', {allowLinker: true});
ga('require', 'linker');
ga('linker:autoLink', ['other-domain.com'] );
ga('send', 'pageview');
ga('create', 'UA-yyyyyyyy-y', 'auto', {name: 'second', allowLinker: true});
ga('second.require', 'linker');
ga('second.linker:autoLink', ['other-domain.com'] );
ga('second.send', 'pageview');
Notice the second. prefix on all the method calls in the second block which corresponds to the name "second" that I gave the tracker.
For more information on the auto-linker plugin, check out this resource:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autolink
And for more information on the various methods and method signatures, here is the guide:
https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference

Multi google codes in one page

We have this code on the website.
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40584814-1', 'webistename.com');
ga('send', 'pageview');
</script>
How can I add another account to it? Can I add something like this?
Can I add something like this?
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40584814-1', 'webistename.com');
**ga('create', 'UA-472147-1', 'webistename.com');**
ga('send', 'pageview');
</script>
I tried that and I can't see the stats on the new account. How can I achieve this? I know I could invite someone via an email but I want to add a completely new account.
Thanks!
Since you're using Universal Analytics (not the original Async version), you have to pass it within the create statement via the options object:
ga('create', 'UA-XXXXXX-X');
ga('create', 'UA-XXXXXX-Y', 'auto', {
'name': 'foo'
});
// later on...
ga('send', 'pageview'); // sends to account XXXXXX-X
ga('foo.send', 'pageview'); // sends to account XXXXXX-Y
The documentation
Asynchronous tracking code my friend ;)
https://developers.google.com/analytics/devguides/collection/gajs/?hl=pl#MultipleCommands

Resources