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.

Integrate Segment with Google Tag Manager

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.

Segment is a customer data infrastructure (CDI) platform that helps you collect, clean, and control your customer data. Learn more at https://segment.com/docs/spec/ecommerce/v2/#event-lifecycles

Search Page
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: searchPage

HTML

<script>
require(['DataLayerSearchApi'], function (DataLayerSearchApi) {
    var search = DataLayerSearchApi();

   analytics.track('Products Searched', {
      query: search.getSearchTerm()
   });
});
</script>
Product List Viewed
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: categoryPage

HTML

<script>
require(['DataLayerCategoryApi'], function (dataLayerCategoryApi) {
    var category = dataLayerCategoryApi();
    
    var segmentProductFormat = {
        renameFieldTo: {
            p_id: 'product_id',
            id: 'sku',
            name: 'name',
            price: 'price',
            position: 'position',
            category: 'category',
            url: 'url',
            image_url: 'image_url'
        },
        appendIndex: false
    };
    
    analytics.track('Product List Viewed', {
      list_id: 'category_page',
      category: category.getCategory('name'),
      products: category.getItems(segmentProductFormat)
    });   
});
</script>
Product Clicked
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: productClick

HTML

<script>
require(['DataLayerProductApi'], function (dataLayerProductApi) {
    var product = dataLayerProductApi();
    
    var renameFieldTo = {
        p_id: 'product_id',
        id: 'sku',
        name: 'name',
        price: 'price',
        position: 'position',
        category: 'category',
        url: 'url',
        image_url: 'image_url'
    };
        
    analytics.track(
        'Product Clicked',
         product.getProductClickDetail(renameFieldTo)
    });
       
});
</script>

*Enhanced Ecommerce and/or Ga4 extension required for this functionality.

Product Page View
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: productPage

HTML

<script>
require(['DataLayerProductApi'], function (dataLayerProductApi) {
    var product = dataLayerProductApi();
    
    analytics.track('Product Viewed', {
      product_id: product.getId(),
      sku: product.getSku(),
      category: product.getCategory(),
      name: product.getName(),
      //brand: 'MagePal',
      //variant: '200 pieces',
      price: product.getPrice(),
      //quantity: 1,
      //coupon: 'MAYDEALS',
      currency: product.getCurrencyCode(),
      position: product.getDataItem('list_position', 1),
      //value: 18.99,
      url: product.getUrl(),
      image_url: product.getProduct('image_url')
    });    
});
</script>
Add To Cart
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: All Custom Events
  Event Name : addToCart

HTML

<script>
require(['DataLayerProductApi'], function (dataLayerProductApi) {
    var product = dataLayerProductApi();
    
    var segmentProductFormat = {
        renameFieldTo: {
            p_id: 'product_id',
            id: 'sku',
            name: 'name',
            variant: 'variant',
            price: 'price',
            quantity: 'quantity',
            position: 'position',
            category: 'category',
            url: 'url',
            image_url: 'image_url'
        },
        appendIndex: false
    };
    
    var items = product.getAddedToCartItems(segmentProductFormat);
    
    for (index in items) {
        analytics.track('Product Added', items[index]);
    }

});
</script>

*Enhanced Ecommerce and/or Ga4 extension required for this functionality.

Product Removed
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: All Custom Events
  Event Name : removeFromCart

HTML

<script>
require(['DataLayerProductApi'], function (dataLayerProductApi) {
    var product = dataLayerProductApi();
    
    var segmentProductFormat = {
        renameFieldTo: {
            p_id: 'product_id',
            id: 'sku',
            name: 'name',
            variant: 'variant',
            price: 'price',
            quantity: 'quantity',
            position: 'position',
            category: 'category',
            url: 'url',
            image_url: 'image_url'
        },
        appendIndex: false
    };
    
    var items = product.getRemovedFromCartItems(segmentProductFormat);
    
    for (index in items) {
        analytics.track('Product Removed', items[index]);
    }

});
</script>

*Enhanced Ecommerce and/or Ga4 extension required for this functionality.

0

Total Downloads

11

years experience with Magento

30+

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

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.

Catalog Hover Image for Magento

Quickly previewing alternative product images on your category list page.

Order Shipment Tracking

Providing your customer with a beautiful and functional order package tracking without leaving your site.