Submit a request

Google Tag Manager (15)



  • Avatar
    Just watched the installation video and that seems to be exactly what they recommend. Can you comment more on what you're wanting?
  • Avatar
    Jeremy Roberts
    GTM help files suggest the best possible place for the GTM script to be immediately after the tag (although it will function if placed in the , Google prefers it after ). THE PROBLEM is that if I place the GTM script on the templates, such as after: This puts the GTM script into the page and it fails to load (and tosses errors) BESIDES WHERE GTM is placed, the integration of Google Analytics into GTM must be looked at as well. The implementation of Google Analytics tag in GTM is pretty basic/easy — but for ecommerce tracking, breaking out the merge codes is not entirely obvious to me (but I’m very close)... Tag: Universal Analytics Tracking ID: yes Track Type: Transaction > To use this option, your webmaster must have set up the data layer on your page above your Google Tag Manager snippet according to the suggested data layer variables Ok, I get all of this... Google wants it to look like this: Here's an example of how this would look (from google help article): dataLayer = [{ 'transactionId': '1234', 'transactionAffiliation': 'Acme Clothing', 'transactionTotal': 38.26, 'transactionTax': 1.29, 'transactionShipping': 5, 'transactionProducts': [{ 'sku': 'DD44', 'name': 'T-Shirt', 'category': 'Apparel', 'price': 11.99, 'quantity': 1 },{ 'sku': 'AA1243544', 'name': 'Socks', 'category': 'Apparel', 'price': 9.99, 'quantity': 2 }] }]; (the example above is for two items) NOW — when an AmeriCommerce sale fires using the (undocumented) mergecode within the GA script: ##GOOGLECONVERSIONTRACKINGUNIVERSALEXCLUDEDSHIPPINGTAX## this is what we see on page: ==================== ga('require','ecommerce','ecommerce.js'); ga('ecommerce:addTransaction', { 'id': '150103', 'affiliation': 'Store Name', 'revenue': '100.00', 'shipping': '0.00', 'tax': '0.00' }); ga('ecommerce:addItem', { 'id': '12345', 'name': 'Product-101', 'sku': '101', 'category': 'Category1', 'price': '100.00', 'quantity': '1' }); ga('ecommerce:send'); ==================== So for GTM, It appears that we need to break this into a bunch of pieces: The merge codes in magenta should work, right? but I am not sure how to get the transactionProducts fields, especially if there is a list of items... ? I know I am very close to a solution here: dataLayer = [{ 'transactionId': '##ORDERID##', 'transactionAffiliation': '##STORENAME##', 'transactionTotal': ##ORDERDISCOUNTEDSUBTOTAL##, 'transactionTax': ##ORDERTAX##, 'transactionShipping': ##ORDERSHIPPING##, 'transactionProducts': [{ 'sku': 'DD44', 'name': 'T-Shirt', 'category': 'Apparel', 'price': 11.99, 'quantity': 1 },{ 'sku': 'AA1243544', 'name': 'Socks', 'category': 'Apparel', 'price': 9.99, 'quantity': 2 }] }]; Are there merge codes that I can use to fill the ‘transactionProducts' fields? I investigated: ##ADDITEM## and ##ADDITEMASYNC## - but these format in a very specific way that is not what GTM is looking for. IN A PERFECT WORLD, we would have a mergecode that would be the equivalent of: [{ 'sku': 'DD44', 'name': 'T-Shirt', 'category': 'Apparel', 'price': 11.99, 'quantity': 1 [##IF_PRODUCTS_MORE_THAN_1##] },{ 'sku': 'AA1243544', 'name': 'Socks', 'category': 'Apparel', 'price': 9.99, 'quantity': 2 }] I wanted to demonstrate that I did my homework on this and am very close to solving this for everyone... There are real benefits to using GTM for Google Analytics (and it is extremely simple yet incredibly powerful). Benefits include more accurate reporting, faster pageload times (because core elements of the script are cached by many users). Hard not to want to use it to make the sites better. WE NEED the mergecode to insert the products into the datalayer. Let's vote early and often!
  • Avatar
    Jeff Owens
    Jeremy, You are correct. Because the AC/Sparkpay framework is built on .NET, the templates as you discovered will be wrapped in a parent -- this is how .NET handles WebForms events. AC/Sparkpay are likely using a MasterPage in the framework but since we don't have access to that, we are unable to inject GTM immediately after the as GTM recommends and you mentioned. The solution is to place the GTM call in the . You can use the Store Settings -> Marketing -> General -> Misc -> "Analytics Script" area to place your GTM snippet. Then, because the new GTM and Google's Universal Analytics (and even the new Enhanced Ecommerce) recommend using the dataLayer method, you'll need to also have your dataLayer populated before GTM fires. In order to do so, you'll need to place all your dataLayer building also in the of your Head Tags template -- it will be injected before the GTM snippet automatically when assembled by the framework. To support this, your GTM Tags are likely set to fire on "All Pages" (or only on the Order View page for conversion). As the page is rendered by the browser, when the GTM load event fires, it will be able to see your dataLayer data and you'll be tracking. What's important to understand here, is that because all of this has to happen BEFORE the DOM (eg. HTML page rendering) is constructed, you won't be able to screen scrape to get the values for items, quanity, amounts, etc from the HTML elements (like from jQuery) because they get built too LATE in the page life-cycle. You have to use the merge codes found in the AC/Sparkpay KB ("Order Base Merge Codes" section) to help you assemble this data in the before the page loads fully; you willy need some JS work done to help to parse these values in a compatible format for the dataLayer. Lastly, it is unfortunate but I've recently discovered that you'll be out of luck for any other relevant merge code data outside of the Order View page. So while you can build UA tracking and AdWords tracking using the DOM, there's no pre-DOM merge codes for build line item based data. :) Anyways, hopefully I was able to help some... :) P.S. Here are some of the merges we're using to accomplish all this: ##ORDERITEMLISTPIPESEPARATED## ##ORDERQUANTITYLISTPIPESEPARATED## ##ORDERPRICELISTQUOTED## ##ORDERCATEGORYLISTPIPESEPARATED## ##ORDERSUBTOTAL## ##ORDERTAX## ##ORDERSHIPPING## ##ORDERTOTAL##
  • Avatar
    Jeff Owens
    NOTE: As a clarification on my "Head Tags" comment -- you'll use the in your page template (eg. Order View) to place all your dataLayer building code so that it will get inserted into the of the rendered output.
  • Avatar
    Carol Ko

    After 3 years... I would like to ask did anyone find a solution to where to place the Google Tag Manager code?  Thanks for sharing!!!

Please sign in to leave a comment.

We're Here To Help

Standard Support Hours: Monday-Friday 8AM-6PM CST
Looking for Premium Support? Just ask!

Speak to a live person
1 (800) 936-9006
Submit A Support Ticket
Submit Your Ticket Here