Push the limits of your Adobe Commerce store with MagePal Extension

Take your Adobe Commerce store to new heights with the power of MagePal extensions. Our expertly crafted code and rigorous testing ensure seamless integration with Adobe Commerce, giving you the freedom to focus on growing your business, not debugging. Upgrade your store's potential with MagePal.

Affiliate sales tracking with Magento + Google Tag Manager + Google Analytics

Please Note: The settings below require our Datalayer for Google Tag Manager for Magento and some features also require our Enhanced Ecommerce or Google Analytics 4 extensions.

All Page View

Set cookie if user Affiliate user (site.com/?ies=abc123)

Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: All Pages


require(['DataLayerApi'], function (dataLayerApi) {
    var dataHelper = dataLayerApi();
    <!-- set cookie -->
    var urlKey = 'ies';
    var cookieName = 'affiliate_tracking';
    var lifetime = 60 * 60 * 24 * 30; // 30 days
    dataHelper.saveTrackingCodeIfKeyExist(urlKey, cookieName, lifetime);

To push the data to GA you can implement it in 1 or 2 ways


####### Rewrite the data layer before sending the information to GA

Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: All Custom Events
  Event Name : purchase


require(['DataLayerPurchaseApi'], function (dataLayerPurchaseApi) {
    var purchase = dataLayerPurchaseApi();
    var cookieName = 'affiliate_tracking';
    var cookieValue = null;
    var data = {
      event: 'affiliatePurchase'  
    if (cookieValue = purchase.getTrackingCodeIfKeyExist(cookieName, true)) {
        data.ecommerce =  {
            'purchase': {
                'actionField': {
                    'affiliation': cookieValue


Please Note: You will need to change your “purchase” event for tracking of order placement to ‘affiliatePurchase’, since it will take a few millisecond to load


Total Downloads


years experience with Magento


Magento / Adobe Commerce Extensions

Shop with confidence

With millions of downloads worldwide, install with confidence knowing that our extensions will just work.

Learn More About MagePal Extension

Is your Magento store ready for the future? Say hello to the new Google Analytics 4, which is built from the ground up with all-new features and advanced machine learning technology.

GA4 Extension


Related Extensions

Streamline your e-commerce operations and boost your sales with MagePal Magento 2 extensions.

Enhanced Success Page

Add cross-sell, upsell, related products, social media links and other elements to your order confirmation.

HTML Minifier for Magento2

Minification is the process of removing all unnecessary characters and spacing from your source code without changing its functionality.

Magento Enhanced E-commerce

If your are using Magento + Google Analytics, then you need Enhanced E-commerce for Google Tag Manager.