Google tag manager is a tag management system that creates tags and passes user interaction data. Rather than setting up everything manually, Google Tag Manager gives space to create complex & custom tags, saves time, adds scalability to your site implementation and most importantly, it’s easy to use. Implementing Google Analytics through Google Tag Manager needs much efforts but ultimately it simplifies future upgrades & enhancements as modifications can be done through GTM rather than each page of your website. Here, we will show you how to setup Google Analytics in Magento with Google Tag Manager.

Steps to setup Google Tag Manager in Magento:

    1. First of go to Google Tag Manager, add your account if already not created. Here you can find your container ID, click on it and you can find two codes to paste in your website pages.1_GTM-container-ID
    2. Copy the code and paste both of them exactly below body tag of your website. Here you will find instructions to put both the code at different places but it’s not working properly in Magento. So follow our instruction as above.
      2_GTM-tracking-code

Setup Google Analytics:
The below steps are same as inserting analytics code into site which will start tracking page views and other information.

      1. Go to Google Tag Manage, Open “Overview” tab and click “Add New Tag”.3_New-tag-for-analytics
      2. Name the tag with “Universal Analytics” and click “Choose a tag type to begin setup”. 4_Tag-config
      3. Select tag type as “Universal Analytics” from the options.5_tag-type-selection
      4. Go to Google Analytics and get tracking ID from admin under “Tracking Info” and copy it. If you haven’t created Google Analytics account, create an account first using this guide. 6_Copy-tracking-ID
      5. Insert copied Tracking ID into “Tracking ID” field. Select “Page View” under “Track Type” and then click “Advanced Settings” and select “Once Per Page” under “Tag firing options”.7_setup-universal-analytics
      6. Select “Triggering” section below and click “Choose a trigger to make this tag fire”. 8_Trigger-selection
      7. Select “All Pages”, save the tag and click “Publish” from the admin. 9_Publish-tag
      8. To track live users on your website in Google Analytics, go to your website from another browser, click on some links. Open Real time –> Overview in Google Analytics. Here you can see total number of live users with other related details. 10_Tracking-enabled-in-analytics

Set up Ecommerce Transactions:

      1. Go to GTM, open “Variables” tab. Under “User-Defined” variables and click “New”. Create new variable, name it “currencyCode”. Now click “Choose a variable type to begin setup”.11_Ecommerce-tracking-adding-variable
      2. Select variable type as Data Layer Variable.12_datalayer-selection
      3. Enter “currencyCode” as “Data Layer Variable Name”. Keep the Data Layer version selected as version 2 and click “save”.13_variable-config
      4. Now go to “Overview” tab and click “Add a new tag”. Enter tag name as “Order” and click “Choose a tag type to begin setup”. Click “Universal Analytics” under tag type. Insert Google Analytics tracking ID just as we did before. Here, select “Transaction” as track type. Now click “More settings” –> “Fields to set” –> “Add Field” and enter Field Name “currencyCode” and Value as {{currencyCode}}.14_Tag-Configuration
      5. Now go to triggering section and click “Choose a trigger to make this tag fire”. Click + sign from the top right corner. Enter trigger name as “Order” and click “Choose a trigger type to begin setup”. From “Choose trigger type”, select “DOM Ready”. Now select “Some DOM Ready Events” under “This trigger fires on” and select values “Page URL”, “Contains” respectively and insert “checkout/onepage/success” into the third field which is Magento default success order page. If you have custom URL for success page, add that path. Save the trigger. After saving the trigger you will see the summary of creating the tag. Click “Save” and then “Publish”.15_Trigger-Config
      6. Now go to Google Analytics and click on Ecommerce Settings in admin panel. Enable Ecommerce, click “Next Step” and Submit. 16_Ecommerce-setup-in-analytics
      7. Now put the following code in your success.phtml file available at \app\design\frontend\[your_theme_package]\template\checkout\success.phtml
      8. After setting up as above, you can track Ecommerce Transactions in Google Analytics at Conversions –> Ecommerce –> Transactions. To test Ecommerce Transactions, place some test orders from your store. Check back Google Analytics at above path and you can see the Ecommerce Transactions data. Note that Ecommerce transactions are not displayed real time. Usually it takes up to 24 Hours to refresh the transaction data so just check back if you can’t find transaction. 17_Ecommerce-tracking-in-analytics

Hope this step by step guide has enough helped you to setup Google Tag Manager in Magento. Still, if you find any queries or you stuck somewhere, let me know, I’ll be glad to help you. Send your feedback through commenting.

Even you can Download PDF of this guide to save for later use.

Click to rate this post!
[Total: 8 Average: 4.6]