Analytics
3.4K members online now
3.4K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm having some trouble getting the Ecommerce tracking code to pull the items data from my website. Below is the code that I'm been using with no success. It's show that there are transaction happening but that's about it. Any ideas?

 

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XX-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans', '_setCustomVar'
'transactionId:', // transaction ID - required
'affiliation:', // affiliation or store name
'OrderTotal:', // total - required
'TaxTotal:', // tax
'ShippingTotal:', // shipping
'city:', // city
'state:', // state or province
'country:' // country
]);

// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each

_gaq.push(['_addItem',
'transactionID:', // transaction ID - required
'item.VariantSku:', // SKU/code - required
'product:', // product name
'size:', // category or variation
'item.Price:', // unit price - required
'item.Quantity' // quantity - required
]);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author adam w
January 2016

Re: Ecommerce Tracking Code not working properly

Top Contributor
# 2
Top Contributor
Hi Adam,

Your code is an outdated version, it is recommended to use the Universal Analytics tracking code:

https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce

Or for Enhanced Ecommerce:

https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce

You can implement it using Google Tag Manager Also:

https://support.google.com/tagmanager/answer/6107169?hl=en

You need to pull the transaction and product values into the tracking code dynamically.

Let me know if you have questions.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author adam w
January 2016

Re: Ecommerce Tracking Code not working properly

Top Contributor
# 2
Top Contributor
Hi Adam,

Your code is an outdated version, it is recommended to use the Universal Analytics tracking code:

https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce

Or for Enhanced Ecommerce:

https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce

You can implement it using Google Tag Manager Also:

https://support.google.com/tagmanager/answer/6107169?hl=en

You need to pull the transaction and product values into the tracking code dynamically.

Let me know if you have questions.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hey Arnold,

Thank you for getting back with me so fast. Meant a lot. I followed your steps and added this code:

<script type="text/javascript">
ga('create', 'xx-xxxxxxxx-x', 'auto');
ga('require', 'ec');
ga('ecommerce:send');

ga('ec:addImpression', {
'id': '', // Product details are provided in an impressionFieldObject.
'name': '',
'category': '',
'brand': '',
'variant': '',
'list': '',
'position': 1 // 'position' indicates the product position in the list.
});

ga('ec:addProduct', { // Provide product details in an productFieldObject.
'id': '', // Product ID (string).
'name': '', // Product name (string).
'category': '', // Product category (string).
'brand': '', // Product brand (string).
'variant': '', // Product variant (string).
'position': 2 // Product position (number).
});

ga('ec:setAction', 'detail','add'); // Detail action.
ga('send', 'pageview'); // Send product impressions with initial pageview.
ga('send', 'event', 'detail view', 'click', 'addToCart');

</script>


Do you see any error in this or is this the proper way to use the google enhanced ecommerce plugin?

Re: Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Also, I just tried to send a transaction from the website to google and received not data or information from the ecommences code. I believe I'm close to figuring this out but still need a little guidance.

Re: Ecommerce Tracking Code not working properly

Top Contributor
# 5
Top Contributor
Hi Adam,

Adding the code as it is in the documents is not enough, you will need server side scripting to populate the fields with values. You need a developer to help with it, enhanced ecommerce is pretty difficult to implement.

Hope this helps.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Hey Arnold,
Can you point to any documentation, that can correctly guide me with enhanced ecommerce.

Re: Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
This is the one we use:
https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce

Though I would recommend that you use Google Tag Manager where it is much easier to control it all:
https://developers.google.com/tag-manager/enhanced-ecommerce

Ecommerce Tracking Code not working properly

[ Edited ]
Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

Thanks Much Dennis,

What I really want to know is,

 

If I want to have addImpression for all of my products, I want to add this code separately in all the product pages for ecommerce tracking.?

 

ga('ec:addImpression', {            // Provide product details in an impressionFieldObject.
 
'id': 'P12345',                   // Product ID (string).
 
'name': 'Android Warhol T-Shirt', // Product name (string).
 
'category': 'Apparel/T-Shirts',   // Product category (string).
 
'brand': 'Google',                // Product brand (string).
 
'variant': 'Black',               // Product variant (string).
 
'list': 'Search Results',         // Product list (string).
 
'position': 1,                    // Product position (number).
 
'dimension1': 'Member'            // Custom dimension (string).
});

 

Appreciate your reply.

 

Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

Please sir I have a website that doesn't use code perse where I can copy and past snippets or tracking for eCommerce.  It does have eCommerce and I do have a property id but it keeps telling me it's not finding the "eCommerce" tag and forget the adding tag thing it's been difficult to figure out so I'm asking what else may I do?  tgssource1111.simdif.com

Ecommerce Tracking Code not working properly

Visitor ✭ ✭ ✭
# 10
Visitor ✭ ✭ ✭

I like the support and the fast replies to solve your problem wow man google are very fast lol