DataLayer for Google Tag Manager
How To Configure
Purchase Extension

Related Extensions

Get more from your Magento2 store!

Order Shipment Tracking

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

Enhanced Transactional Emails

Get more from your order confirmation emails by promoting other complementary products.

Enhanced Success Page

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

Integrate CJ Affiliate with Google Tag Manager

All Page View

Set cookie if user is coming from a CJ Affiliate (site.com/?cjevent=abc123)

Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: All Pages

HTML

<script>
require(['DataLayerApi'], function (dataLayerApi) {
    var dataHelper = dataLayerApi();
    
    <!-- CJ Affiliate Code -->
    dataHelper.saveTrackingCodeIfKeyExist("cjevent");
    <!-- CJ Affiliate Code -->
});
</script>
Purchase
Tag Configuration
  Tag type : Custom Html

Trigger Configuration
  Trigger: All Custom Events
  Event Name : purchase

HTML

<script>
require(['DataLayerPurchaseApi'], function (dataLayerPurchaseApi) {
    var purchase = dataLayerPurchaseApi();

    var queryParms = {
        containerTagId: 'Add your Container Tag Id here',
        OID: purchase.getOrderId(),
        TYPE: 'Add your Type Id here',
        CURRENCY: purchase.getCurrencyCode(),
        DISCOUNT: purchase.getOrder('discount'),
        COUPON: purchase.getOrderCouponCode(),
        CJEVENT: purchase.getTrackingCodeIfKeyExist('cjevent', true)
    };
    
    var cjFormat = {
        renameFieldTo: {id:'ITEM', quantity:'QTY', price:'AMT'},
        appendIndex: true
    }; 
    
    var cjItems = purchase.getItems(cjFormat);
    
    purchase.setUrlDomain('//www.emjcd.com/tags/c/');
    purchase.addUrlParams(queryParms);
    purchase.addUrlParams(cjItems);
    
    var url = purchase.buildUrl();
    purchase.addIframe(url);
});
</script>
Related

Related Extensions

Get more from your Magento2 store!

Enhanced Transactional Emails

Get more from your order confirmation emails by promoting other complementary products.

Magento Enhanced E-commerce

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

Order Shipment Tracking

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