Skip to content

Instantly share code, notes, and snippets.

@twesolowski
Created September 11, 2018 12:44
Show Gist options
  • Save twesolowski/85e83cd53f047a74a8bb5fdc8bed7eea to your computer and use it in GitHub Desktop.
Save twesolowski/85e83cd53f047a74a8bb5fdc8bed7eea to your computer and use it in GitHub Desktop.
jashdatalayer

README

DataLayer on every page

dataLayer.push({
    "siteType": "desktop",
    "event": "contact",
    "language": "en",
    "currency": "GBP"
});

Home page

dataLayer.push({
    "siteType": "desktop",
    "event": "index",
    "language": "en",
    "currency": "GBP"
});

Category page

dataLayer.push({
    "siteType": "desktop",
    "event": "category",
    "language": "en",
    "currency": "GBP",
    "viewItem": 3,
    "items": ["1", "2", "3", "4", "5", "6", "7"]
});

Cart

dataLayer.push({
    "siteType": "desktop",
    "event": "cart",
    "language": "en",
    "currency": "GBP",
    "items": [{
        "id": "1",
        "price": 19.812,
        "quantity": 1
    }, {
        "id": "2",
        "price": 32.399822,
        "quantity": 1
    }, {
        "id": "3",
        "price": 31.199822,
        "quantity": 1
    }, {
        "id": "4",
        "price": 61.192984,
        "quantity": 1
    }, {
        "id": "5",
        "price": 34.777206,
        "quantity": 1
    }, {
        "id": "6",
        "price": 36.603083,
        "quantity": 1
    }]
});

Order confirmation

dataLayer.push({
    "siteType": "desktop",
    "event": "order-confirmation",
    "language": "en",
    "currency": "GBP",
    "client": "57d80925ffa2ac613681f3f408ce69f2",
    "transaction": {
        "transactionId": 7,
        "transactionTotal": "224.380000",
        "transactionTax": 37.4,
        "item": [{
            "id": "1",
            "price_wt": "19.812000",
            "price_te": "16.510000",
            "quantity": "1"
        }, {
            "id": "2",
            "price_wt": "32.399822",
            "price_te": "26.999852",
            "quantity": "1"
        }, {
            "id": "3",
            "price_wt": "31.199822",
            "price_te": "25.999852",
            "quantity": "1"
        }, {
            "id": "4",
            "price_wt": "61.192984",
            "price_te": "50.994153",
            "quantity": "1"
        }, {
            "id": "5",
            "price_wt": "34.777206",
            "price_te": "28.981005",
            "quantity": "1"
        }, {
            "id": "6",
            "price_wt": "36.603083",
            "price_te": "30.502569",
            "quantity": "1"
        }]
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment