Git Product home page Git Product logo

gtm-template-tag-google-ecommerce-data-transfer's Introduction

Custom Template for Google Tag Manager: Google Enhanced Ecommerce data transfer to remarketing pixels

This tag gets data from Google Enhanced Ecommerce configured via dataLayer and sends it to dynamic remarketing pixels:

This tag uses Google Enhanced Ecommerce configured via dataLayer to get event and product data, so you need it to be on your site, otherwise this tag will not work.

This tag intercepts dataLayer.push, so it should be fired only via All Pages or DOM Ready triggers.

You can run several copies of the tag on the page, for example, one for VK, the second for Facebook, etc.

The tag injects this script to the site for its work.

If your security policy does not allow loading third-party scripts, you can install this data transfer script as a GTM Custom HTML tag. In this case, no third-party scripts will be loaded to your site. To do this, fill the settings object in the code with your data and set All Pages trigger for this GTM Custom HTML tag.

Events and event data structure

Pixels events and data structure of each event are compiled in accordance with the official documentation of each pixel.

The tag doesn't add anything from itself to the event or product data, it takes only what is in Google Enhanced Ecommerce. If Google Enhanced Ecommerce is missing something, it will be absent in dynamic remarketing pixels as well.

Description of events and data structures:

Website homepage view.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids // Product categories, for example: 'phones,tablets,headphones'
    }
}

Website catalog page view.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids // Product categories, for example: 'phones,tablets,headphones'
    }
}

Page with site search results view.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids, // Product categories, for example: 'phones,tablets,headphones'
        search_string // Search query
    }
}

Other page view.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids // Product categories, for example: 'phones,tablets,headphones'
    }
}

Product detail view.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids, // Product categories, for example: 'phones,tablets,headphones'
        currency_code, // Currency code
        total_price // Total price
    }
}

Add product to cart.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids, // Product categories, for example: 'phones,tablets,headphones'
        currency_code, // Currency code
        total_price // Total price
    }
}

Remove product from cart.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids, // Product categories, for example: 'phones,tablets,headphones'
        currency_code, // Currency code
        total_price // Total price
    }
}

Checkout process start.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids, // Product categories, for example: 'phones,tablets,headphones'
        currency_code, // Currency code
        total_price // Total price
    }
}

Product purchase.

Event data structure:

{
    priсeListID, // Price list ID
    name, // Event name
    {
        [
            {
                id, // Product ID
                group_id, // Product brandname
                price // Product price
            },
            
        ],
        category_ids, // Product categories, for example: 'phones,tablets,headphones'
        currency_code, // Currency code
        total_price // Total price
    }
}

Website homepage view.

Event data structure:

{
    'trackCustom', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type // Product type
    }
}

Website catalog page view.

Event data structure:

{
    'trackCustom', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type // Product type
    }
}

Page with site search results view.

Event data structure:

{
    'track', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_category, // Product categories, for example: 'phones,tablets,headphones'
        search_string // Search query
    }
}

Other page view.

Event data structure:

{
    'trackCustom', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type // Product type
    }
}

Product detail view.

Event data structure:

{
    'track', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type, // Product type
        currency, // Currency code
        value // Total price 
    }
}

Add product to cart.

Event data structure:

{
    'track', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type, // Product type
        currency, // Currency code
        value // Total price 
    }
}

Remove product from cart.

Event data structure:

{
    'trackCustom', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type, // Product type
        currency, // Currency code
        value // Total price 
    }
}

Checkout process start.

Event data structure:

{
    'track', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_category, // Product categories, for example: 'phones,tablets,headphones'
        num_items, // Number of product items
        currency, // Currency code
        value // Total price 
    }
}

Product purchase.

Event data structure:

{
    'track', // Method of data send
    name, // Event name
    {
        [
            {
                id, // Product ID
                quantity, // Product quantity
                item_price // Product price
            },
            
        ],
        content_name, // Product names, for example: 'Apple iPhone X Black,Samsung Galaxy A80 128Gb'
        content_type, // Product type
        currency, // Currency code
        value, // Total price 
        num_items // Number of product items
    }
}

Website homepage view.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list // Feed ID
}

Website catalog page view.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list // Feed ID
}

Page with site search results view.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list // Feed ID
}

Other page view.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list // Feed ID
}

Product detail view.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list, // Feed ID
    totalvalue // Total price
}

Add product to cart.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list, // Feed ID
    totalvalue // Total price
}

Product purchase.

Event data structure:

{
    id, // Counter ID
    type, // Event type
    [productid, ], // Product ID(s)
    pagetype, // Event name
    list, // Feed ID
    totalvalue // Total price
}

gtm-template-tag-google-ecommerce-data-transfer's People

Contributors

d9i2r2t1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

vmatkarimov

gtm-template-tag-google-ecommerce-data-transfer's Issues

Display Name Length

Consider shortening the display name field to make this a template a little more digestible when displayed in the Gallery

2 pixels giving problems

I have a client with an ecommerce store built in opencart. They are running their own facebook pixel with the official facebook extension for opencart. I need another pixel installed so I used google tag manager. I am using the Google Tag Manager template for Facebook pixel by Simo Ahava to fire the pixel across the website. I need to use that because if I only use your template, the pixel is not firing on other events.

The problem I'm having is that your template isn't passing the ecommerce variables to the facebook pixel all the time. 1 out of 20 times, it will fire another event and pass the variables to those. So I get 2 Purchase events fired, one has no variables forwarded to it, the second one has all the variables required forwarded.

I need it to fire all the time, and for there to be one of each events required. How do I get that done?

Thank you in advance!!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.