Google Tag Manager for Magento2 with Data Layer

Total Downloads Latest Stable Version

Google Tag Manager allows you to quickly and easily add or update AdWords, Google Analytics, Facebook Tags and other code snippets on your website without edit to your magento 2 codebase.

Google Tag Manager for Magento


  • Quick and easy setup
  • Add tag via XML layout and/or observer
  • Data layer support


Step 1

Using Composer (recommended)
composer require magepal/magento2-googletagmanager
Manually (not recommended)
  • Download the extension
  • Unzip the file
  • Create a folder {Magento 2 root}/app/code/MagePal/GoogleTagManager
  • Copy the content from the unzip folder

Step 2 - Enable GTM ("cd" to {Magento root} folder)

  php -f bin/magento module:enable --clear-static-content MagePal_GoogleTagManager
  php -f bin/magento setup:upgrade

Step 3 - Configure GTM

Log into your Magento 2 Admin, then goto Stores -> Configuration -> MagePal -> Google Tag Manager and enter your GTM account credentials

Data layer attributes

  • Trigger: event equals gtm.dom
    • pageType (i.e catalog_category_view)
    • list (cart, category, detail, other)


  • Trigger: event equals mpCustomerSession
    • customer.isLoggedIn
    • customer.groupId


  • Trigger: event equals gtm.dom
    • category.path


  • Trigger: event equals gtm.dom
    • product.sku
    • product.path


  • Trigger: event equals mpCustomerSession
    • cart.hasItems
    • cart.items[].sku
    • cart.items[].name
    • cart.items[].price
    • cart.items[].quantity
    • cart.itemCount
    • cart.itemQty
    • cart.hasCoupons
    • cart.couponCode


  • Trigger: event equals gtm.dom
    • transactionId
    • transactionAffiliation
    • transactionTotal
    • transactionShipping
    • transactionTax
    • transactionCouponCode
    • transactionDiscount
    • transactionSubTotal
    • transactionProducts[].sku
    • transactionProducts[].name
    • transactionProducts[].price
    • transactionProducts[].quantity


Want to contribute to this extension? The quickest way is to open a pull request on GitHub.


If you encounter any problems or bugs, please open an issue on GitHub.

Need help setting up or want to customize this extension to meet your business needs? Please email and if we like your idea we will add this feature for free or at a discounted rate.

© MagePal LLC. |