Reputation: 270
Previously, our enhanced ecommerce tracking was working properly as follows:
ga('create', 'UA-12345678-1', 'auto');
ga('require', 'ec');
@foreach(var prod in Model.Purchases){
<text>
ga('ec:addProduct', {
'id': '@prod.PolNumber',
'name': '@prod.Name',
'brand': '@prod.Brand',
'quantity': '@prod.Quantity'
});</text>
}
ga('ec:setAction', 'purchase', {
'id': '@Model.id',
'revenue': '@Model.TotalValue'
});
ga('send', 'pageview');
However, once we tried to add cross-domain tracking, which modified the code by changing the first line into three lines:
ga('create', 'UA-12345678-1', 'auto', { 'allowLinker': true });
ga('require', 'linker');
ga('linker:autoLink', ['mynewwebsite.com']);
And then was followed by the remaining code:
ga('require', 'ec');
...
All the way to the end. The code successfully does the cross-domain tracking, but the e-commerce piece isn't showing up in Google Analytics. We don't want to set up two separate trackers, and retrograding to the older e-commerce option Google Analytics provides isn't preferable either.
Upvotes: 0
Views: 155
Reputation: 270
It turns out that the answer, at least on the surface, is NOT code-related. As it so happens, the page redirect that normally would have pointed to this page, thus rendering the analytics code, was changed recently. As a result, the page that contains this analytics code was never being called, and so the analytics was not working.
Upvotes: 0
Reputation: 8907
I believe the correct ga method call is "require", but you have "required":
ga('require', 'ec');
Upvotes: 1