AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
2.1K members online now
2.1K 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

GTM GA Enhanced Ecommerce Question

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Greetings, 

I am trying to setup tracking analytics using GTM and GA.

My problems is that once the page has completed loading, all the layers that I add to the dataLayer  object are not being tracked and I don't see any data sent to GA (using google's collect requests).

 

Once the page is loading, the initial data is sent but any other layers that I add later will do nothing...

 

I've setup a test page with the following scenario:

When the page loads it will parse the following JS code which is located in the head section:

 

    <script>
        window.dataLayer = window.dataLayer || [];
  		window.dataLayer.push({
                ecommerce: {
                    detail: {
                        actionField: '',
                        products: [{
                            id: '12345',
                            name: 'Triblend Android T-Shirt',      // Name or ID is required.   
                            price: '15.25',
                            brand: 'Google'
                        }]
                    }
                }
            });
	</script>

    <!-- Google Tag Manager -->
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-XXXXX');</script>
    <!-- End Google Tag Manager -->

This part of the application is working and I can see that the data is sent to google, however... 

 

Since my application is a single page application, the user interactions are on the same page.

I took the "Add to shopping cart" functionality do demonstrate my issue.

When the user adds new items to the shopping cart, the code will generate the following:

 

window.dataLayer.push({
                event: 'addToCart',
                ecommerce: {
                    currencyCode: 'USD',
                    add: {
                          products: [{
                                name: 'Triblend Android T-Shirt',
                                id: '12345',
                                price: '15.25',
                                category: 'Apparel',
                                quantity: 1
                           }]
                    }
                }
            });

However, even now I get nothing sent to GA...

 

 

In all the demos that i've watch, when a new layer is added to the dataLayer, a corresponding http request is being sent to google servers collecting the data but in my example, nothing happens and I haven't figured out why... 

 

In the GTM, I have the following tags configured:

Capture.PNG

 

In the GA, i've setup the enhanced eCommerce:

Capture2.PNG

 

1 Expert replyverified_user

GTM GA Enhanced Ecommerce Question

Top Contributor
# 2
Top Contributor

hi,

you're missing a GTM trigger that looks for an event named AddToCart.

Define that event then use it to fire a Google Analytics event tag, with the following attributes:

  Category: Commerce

  Action: Add To Cart

Check the eCommerce box and check "use datalayer"

 

Save, publish and enjoy ;-)

VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan