What is a data layer and how do I set it up?
    • 1 Minute to read
    • Dark
      Light

    What is a data layer and how do I set it up?

    • Dark
      Light

    Article summary

    A data layer is a JavaScript object storing various tracking information temporarily. This includes page names, parameters, and product names, but also user-specific information such as customer IDs or target groups.

    If you use the Mapp Tag Integration, it doesn't matter what you call the individual properties, because you have to manually specify where the desired information can be found in the parameter settings anyway.

    However, if you pass the tracking information directly from the page (sendinfo() in V4 and wts.push() in Tag Integration (V5) then you save a few lines of code when you create the data layer as the sendinfo or wts.push method expects the data, because you can pass the data layer directly as an argument.

    Please compare your tracking information with our article Which parameters can be sent to Mapp Intelligence? There, in the column JavaScript Key, you can see with which parameter name the pixel expects the information.

    Here is a simple example:

    var dataLayer = {
        contentId: "testpage",
        customSessionParameter: {
            1: "Session Parameter Value 1",
            2: "Session Parameter Value 2"
        },
        pageType: "Supportpage",
        other: "Is ignored by Mapp Intelligence!"
    };

    If you now want to track a page, you can pass the dataLayer object directly, although with "other" there is a key unknown to Mapp. This value then is simply ignored by the pixel.

    Now you can fire a page request directly like this:

    // with Tag Integration (V5)
    wts.push(["send", "page", dataLayer]);
    
    // without Tag Integration (V4)
    wt.sendinfo(datalayer);

    Comprehensive information on how a data layer works and how to create it can be found in a W3C document that you can download here: https://www.w3.org/2013/12/ceddl-201312.pdf


    Was this article helpful?