GA, Enhanced eCommerce mode, and Google Tag Manager

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • ids
    replied
    For posterity, I did receive confirmation from the client that the eCommerce tag move to the HEAD Tag worked and the "data is flowing."

    Notes:

    -Use the Googe Tag Assistant and do your best to address and solve the errors and even the suggestions
    -Google Tag Manager won't run SMT code, so any scripts with SMT need to be added outside the GTM call
    -when changing the GA Setting to Enhanced eCommerce tag, move the Miva supplied script to the HEAD Tag because it contains SMT and is needed to create the data needed by GA. It appears GA won't find this data set if not in the HEAD Tag.

    Scott

    Leave a comment:


  • ids
    replied
    OK, waiting for verification from the client that I've resolved the issue. Google is as clear (as mud) as can be. The GA Alert flags the issue as resolved.

    Notes:
    I had reproduced nearly everything in my own store -- minus GTM, including the HTTP error.

    - the script I posted, generated by Miva works as standalone and connects with analytics.js.

    I used Google Tag Assistant (thankfully) and my own OCD couldn't live with even the suggestions being reported. That resolved suggestion appears to have been the key. As of this moment, the solution was to adjust the placement of the component items. The default install of the Miva GA module with successful GA ID etc places the items automatically in the Head Tag, Global Footer, and INVC page. (the GA Tutorial in Docs confirms this) In resolving a GTA suggestion, it advised moving the tag inside the HEAD. Miva's default placement is in the global footer. It appears this results in the site/pages not able to send the data. I moved the eCommerce TAG to the HEAD. This appears to have resolved the HTTP response error and it appears the data is flowing. Hopefully, the client finds the same.

    Scott


    Leave a comment:


  • alphabet
    replied
    Yes, you are correct that GTM is out of scope and does not have access to Miva variables.

    It looks like your example is suppose to be simply a loading script that connects to GTM which then document.writes a new script of the Tag Manager container. Tag Manager container can include several endpoint connectors such as GA, Adroll, Pinterest or Crazy Egg and manages their namespaces. GTM is great if there are several shareholders with limited technical ability needing site data without having to use a developer. Just point and click.

    So I think you are getting an HTTP error because GTM is intended to be just a loading script.

    Then the GTM container script reads from the dataLayer and posts the data to Google Analytics Enhanced Ecommerce endpoint.

    If you only need GA then you can probably deprecate GTM and use the tag snippet Google provides and adapt it for Miva with the GA module.

    Leave a comment:


  • ids
    replied
    I think I am missing a step or something along that line.

    I have the same issue in my own store actually. I don't have any GTM. The client does and I have added the script to their global footer. I am assuming GTM is now outside the scope. The following is the Miva generated script inserted when I switch the setting to Enh eC. This is running in the global footer (all pages).
    Just like my client's, there is no data flowing. I am not trying to get metrics on the advertising they are doing. That's where I stand atm. I think I've done what's needed on the Miva side of this equation per the docs. I have the idea that there is more code that needs to be integrated?


    Code:
    <mvt:miva compresswhitespace="off" />
    <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', '<mvt:item name="ga_jsencode" param="ga_tracking:google_id_unencoded" />', 'auto');
    
    var mvga_basketitems = [
    <mvt:foreach iterator="item" array="basket:items">
        <mvt:if expr="l.pos1 GT 1">,</mvt:if>
        {
            'code'        :    '<mvt:item name="ga_jsencode" param="item:code" />',
            'name'        :    '<mvt:item name="ga_jsencode" param="item:name" />',
            'line_id'    :    <mvt:eval expr="int( l.settings:item:line_id )" />,
            'group_id'    :    <mvt:eval expr="int( l.settings:item:group_id )" />,
            'price'        :    '<mvt:eval expr="l.settings:item:price ROUND 2" />',
            'quantity'    :    <mvt:eval expr="int( l.settings:item:quantity )" />
        }
    </mvt:foreach>
    ];
    
    var mvga_orderitems = [
    <mvt:foreach iterator="item" array="order:items">
        <mvt:if expr="l.pos1 GT 1">,</mvt:if>
        {
            'order_id'    :    <mvt:eval expr="int( l.settings:item:order_id )" />,
            'code'        :    '<mvt:item name="ga_jsencode" param="item:code" />',
            'name'        :    '<mvt:item name="ga_jsencode" param="item:name" />',
            'price'        :   '<mvt:eval expr="l.settings:item:price ROUND 2" />',
            'quantity'    :    <mvt:eval expr="int( l.settings:item:quantity )" />
        }
    </mvt:foreach>
    ];
    
    var mvga_productlist = [];
    
    var mvga_tracker = new MVGA_Tracker( '<mvt:item name="ga_jsencode" param="ga_tracking:product_link_prefix" />', '<mvt:item name="ga_jsencode" param="category:name" />', '<mvt:item name="ga_jsencode" param="product:code" />', '<mvt:item name="ga_jsencode" param="product:name" />', mvga_basketitems, mvga_orderitems );
    
    <mvt:if expr="l.settings:page:code EQ 'PROD'">
        ga( 'require', 'ec' );
    
        <mvt:foreach iterator="list_product" array="ga_tracking:product_list">
        ga( 'ec:addImpression',
        {
            'id'        : '<mvt:item name="ga_jsencode" param="list_product:code" />',
            'name'        : '<mvt:item name="ga_jsencode" param="list_product:name" />',
            'list'        : 'Related Products',
            'position'    : '<mvt:eval expr="int( l.settings:list_product:disp_order )" />'
        } ); 
    
        mvga_productlist.push( 
        {
            'code'        : '<mvt:item name="ga_jsencode" param="list_product:code" />',
            'name'        : '<mvt:item name="ga_jsencode" param="list_product:name" />',
            'position'    : '<mvt:eval expr="int( l.settings:list_product:disp_order )" />'
        } );
        </mvt:foreach>
    
        ga( 'ec:addProduct',
        {
            'id'        : '<mvt:item name="ga_jsencode" param="product:code" />',
            'name'        : '<mvt:item name="ga_jsencode" param="product:name" />',
            'category'    : '<mvt:item name="ga_jsencode" param="category:name" />'
        } ); 
    
        ga( 'ec:setAction', 'detail' );
    <mvt:elseif expr="l.settings:page:code EQ 'CTGY' OR
                      l.settings:page:code EQ 'PLST' OR
                      l.settings:page:code EQ 'SRCH'">
        ga( 'require', 'ec' );
    
        <mvt:foreach iterator="list_product" array="ga_tracking:product_list">
        ga( 'ec:addImpression',
        {
            'id'        : '<mvt:item name="ga_jsencode" param="list_product:code" />',
            'name'        : '<mvt:item name="ga_jsencode" param="list_product:name" />',
            'category'    : '<mvt:item name="ga_jsencode" param="category:name" />',
            'list'        : '<mvt:item name="ga_jsencode" param="ga_tracking:list_label" />',
            'position'    : '<mvt:eval expr="int( l.settings:list_product:disp_order )" />'
        } ); 
    
        mvga_productlist.push( 
        {
            'code'        : '<mvt:item name="ga_jsencode" param="list_product:code" />',
            'name'        : '<mvt:item name="ga_jsencode" param="list_product:name" />',
            'position'    : '<mvt:eval expr="int( l.settings:list_product:disp_order )" />'
        } );
        </mvt:foreach>
    <mvt:elseif expr="l.settings:page:code EQ 'OSEL'">
        ga( 'require', 'ec' );
    
        var i;
    
        for ( i = 0; i < mvga_basketitems.length; i++ )
        {
            ga( 'ec:addProduct', 
            {
                'id'        :    mvga_basketitems[ i ].code,
                'name'        :    mvga_basketitems[ i ].name,
                'price'        :    mvga_basketitems[ i ].price,
                'quantity'    :    mvga_basketitems[ i ].quantity
            } );
        }
    
        ga( 'ec:setAction', 'checkout', { 'step' : 1 } );
    <mvt:elseif expr="l.settings:page:code EQ 'OPAY'">
        ga( 'require', 'ec' );
    
        var i;
    
        for ( i = 0; i < mvga_basketitems.length; i++ )
        {
            ga( 'ec:addProduct', 
            {
                'id'        :    mvga_basketitems[ i ].code,
                'name'        :    mvga_basketitems[ i ].name,
                'price'        :    mvga_basketitems[ i ].price,
                'quantity'    :    mvga_basketitems[ i ].quantity
            } );
        }
    
        ga( 'ec:setAction', 'checkout', { 'step' : 2 } );
    <mvt:elseif expr="l.settings:page:code EQ 'INVC'">
        ga( 'require', 'ec' );
    
        <mvt:foreach iterator="ga_orderitem" array="ga_tracking:orderitems">
        ga( 'ec:addProduct', {
            'id'        : '<mvt:item name="ga_jsencode" param="ga_orderitem:code_unencoded" />',
            'name'        : '<mvt:item name="ga_jsencode" param="ga_orderitem:name_unencoded" />',
            'price'        : '<mvt:item name="ga_jsencode" param="ga_orderitem:price" />',
            'variant'    : '<mvt:item name="ga_jsencode" param="ga_orderitem:variant_label_unencoded" />',
            'quantity'     : <mvt:eval expr="l.settings:ga_orderitem:quantity" />
        } );
        </mvt:foreach>
    
        ga( 'ec:setAction', 'purchase', {
            'id'             : '<mvt:eval expr="int( l.settings:ga_orderitem:order_id )" />',
            'revenue'         : '<mvt:item name="ga_jsencode" param="ga_tracking:order_total" />',
            'affiliation'    : '<mvt:item name="ga_jsencode" param="store:name" />',
            'tax'            : '<mvt:item name="ga_jsencode" param="ga_tracking:total_tax" />',
            'shipping'        : '<mvt:item name="ga_jsencode" param="ga_tracking:total_ship" />'
        } );
    </mvt:if>
    <mvt:if expr="( g.UI_Exception NE 1 ) OR ( g.Session:cache:last_ui_exception EQ 'order_invoice' )">
    ga( 'send', 'pageview', { 'page':'<mvt:item name="ga_jsencode" param="ga_tracking:url_override_unencoded" />' } );
    </mvt:if>
    
    </script>
    And, am I correct in thinking that that script will not work in the GTM container?

    Leave a comment:


  • alphabet
    replied
    Hey Scott,

    Good talking to you last week.

    GTM provides the script that is the 'connector' between web page and Google Analytics Enhanced Ecommerce API.

    You will need each page to push an event to the JS Data Layer that the script will read.

    Here is an example of an ecommerce product impression on the CTGY page:

    Code:
      <script data-cfasync="false" type="text/javascript">
          dataLayer.push({
            'ecommerce': {
              'impressions': [
          <mvt:foreach iterator="product" array="category_listing:products">
          <mvt:if expr="l.settings:product:active" >
            <mvt:assign name="g.category_datalayer_index" value="g.category_datalayer_index + 1" />
               {
                 'name': '&mvt:product:name;',
                 'id': '&mvt:product:code;',
                 'price': '&mvt:product:price;',
                 'category': '&mvt:category:name;',
                 'list': 'CTGY',
                 'position': &mvt:global:category_datalayer_index;
               }<mvt:if expr="NOT( g.category_datalayer_index EQ g.category_products_length)">,</mvt:if>
          </mvt:if>
          </mvt:foreach>
              ]
            }
          });
        </script>

    Leave a comment:


  • ids
    replied
    Thanks to Dan for pointing me in the right direction in some direct emails. The remaining part of my question is about no data flowing. I don't know how sensitive GA is regarding this. I'm using the Google Tag Assistant extension for Chrome to help identify errors an suggestions. I am finding that some things that GA detects aren't integrated correctly. One main area is the "No HTTP response" error. Not sure how to fix that one yet, but reads as very important. Ideas what o look for?

    BTW: I am thinking he script Miva generated for the Enhanced eCommerce tags won't actually run inside a GTM Tag manager because the script contains SMT so I placed it outside the GTM call.

    The other odd man out scenario is that I needed to grab the script from another store. Seems the store settings didn't or couldn't generate the script. Is this because the store is MMUI? If so, will script I copied from another store cause a failure? So far the generated/rendered script looks OK. Is it?

    Thanks,

    Scott

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Couple of things come to mind. GTM, can be used to feed into Analytics, but that's a google side issue. I've seen GTM setup as either just SMT/JS in some random template, or (my preference) in place of the GA code in the GA module. (There, we are just using that template as a convenient content holder. Do you have Template GPS or Miva's Search / Replace to track down the location?

    As for tracking GA module issues. I find the most common is that they UA- id tag is incorrect. Next would be other JS errors stepping on the GA JS (they do recommend running the code right after the <body> tag for this reason.

    That's all I got.

    Leave a comment:


  • ids
    started a topic GA, Enhanced eCommerce mode, and Google Tag Manager

    GA, Enhanced eCommerce mode, and Google Tag Manager

    GA is reporting that "Data is not flowing."

    This is an MMUI store and the GA Settings is Enhanced eCommerce. The client is getting the alert that eCommerce mode is on but no data is flowing. I am not sure what is suppose to happen. GA screens lack anything helpful and aren't intuitive and I could spend 8 hours searching for an obscure answer. Trying to avoid that pinch. The other element I found is that a previous developer set up the site with the Google Tag Manager. I haven't run into this yet so I have no experience where scripts are. IOW, when I changed the GA Settings in UTILS to Enhanced eCommerce, the JS should have been updated, I assume. I don't know where the script was updated or if it were suppose to be updated.

    Thanks for any helpful insight.

    Scott

Working...