Product Level Tracking GTM EN

From Wiki

Jump to: navigation, search

Contents

Product Level Tracking (PLT) through Google Tag Manager (GTM)

Product Level Tracking can be used to provide publishers/advertisers with additional information about shopping cart contents/order details for their optimization purposes and/or be used for commission flexibility tool.

If you as an advertiser make use of GTM to display the Awin tracking code, you can easily add product level tracking. The prerequisite is an integrated enhanced e-commerce data layer, see GA4 ecommerce meassurement.

GTM example dataLayer GA4

dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
      transaction_id: "T_12345",
      affiliation: "Google Merchandise Store",
      value: 25.42,
      tax: 4.90,
      shipping: 5.99,
      currency: "USD",
      coupon: "SUMMER_SALE",
      items: [
       {
        item_id: "SKU_12345",
        item_name: "Stan and Friends Tee",
        affiliation: "Google Merchandise Store",
        coupon: "SUMMER_FUN",
        currency: "USD",
        discount: 2.22,
        index: 0,
        item_brand: "Google",
        item_category: "Apparel",
        item_category2: "Adult",
        item_category3: "Shirts",
        item_category4: "Crew",
        item_category5: "Short sleeve",
        item_list_id: "related_products",
        item_list_name: "Related Products",
        item_variant: "green",
        location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
        price: 9.99,
        quantity: 1
      },
      {
        item_id: "SKU_12346",
        item_name: "Google Grey Women's Tee",
        affiliation: "Google Merchandise Store",
        coupon: "SUMMER_FUN",
        currency: "USD",
        discount: 3.33,
        index: 1,
        item_brand: "Google",
        item_category: "Apparel",
        item_category2: "Adult",
        item_category3: "Shirts",
        item_category4: "Crew",
        item_category5: "Short sleeve",
        item_list_id: "related_products",
        item_list_name: "Related Products",
        item_variant: "gray",
        location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
        price: 20.99,
        promotion_id: "P_12345",
        promotion_name: "Summer Sale",
        quantity: 1
      }]
  }
});


The product array (items) should be created as a variable:

File:2022-08-23_134339.png‎
As well as the TransactionId or Order Reference:

File:2022-08-23_140933.png

GTM example code (GA4) for Awin PLT - variant 1

Awin product line specification:

AW:P|{{advertiserId}}|{{orderReference}}|{{productId}}|{{productName}}|{{productItemPrice}}|{{productQuantity}}|{{productSku}}|{{commissionGroupCode}}|{{productCategory}}


Since "productId" and "productSku" are not available in this form, item_id is used here. Of course, a different ID can also be passed if there are separate values ​​in the dataLayer. The advertiser ID from the example (1001) should be replaced with your own.

Custom JavaScript variable - example name: "AWIN PLT"

function() {
  var    productArray =  {{dlv - ecommerce.items}};
  var awin = "";
    for (i = 0; i < productArray.length; i++) { 
    awin += 'AW:P|1001|'
	+{{dlv - ecommerce.transaction_id}}+'|' 
	+productArray[i].item_id+'|'
	+productArray[i].item_name+'|'
	+parseFloat(productArray[i].price).toFixed(2)+'|'
	+productArray[i].quantity+'|'
        +productArray[i].item_id+'|'
	+'Default|'	
        +productArray[i].item_category 
        + "\r\n";
} 
return awin;
}


If the conversion tag from the tag templates has been used, either the entire tag would have to be replaced by customHTML tag or the following part would also have to be triggered as a customHTML tag right before the conversion tag.

CustomHTML Tag - trigger purchase/thank-you page

<form style="display: none;" name="aw_basket_form">
<textarea wrap="physical" id="aw_basket">
{{AWIN PLT}}
</textarea>
</form>


GTM example code (GA4) for Awin PLT - variant 2

Search for Awin in the GTM Tag Template Gallery and add: File:2022-08-23_130931.png
Next, as before, the dataLayer with the transactionProducts should be available. Using the "items" in the product array we can build the array required for Awin:

Custom JavaScript Variable - Example Name: "AWIN PLT Array"

function () {
    var awinProductArray = [];
    for (var i = 0; i < {{dlv - ecommerce.items}}.length; i++) {
        awinProductArray.push({
           'id' : {{dlv - ecommerce.items}}[i].item_id,
           'name' : {{dlv - ecommerce.items}}[i].item_name,
           'price' : {{dlv - ecommerce.items}}[i].price,
           'quantity' : {{dlv - ecommerce.items}}[i].quantity,
           'sku' : {{dlv - ecommerce.items}}[i].item_id,
           'cGroup' : 'DEFAULT',
           'category' : {{dlv - ecommerce.items}}[i].item_category
        })
    }
    return awinProductArray;
}


File:2022-08-23_132059.png
The array would then have to be used in the tag: File:2022-08-23_141634.png


Privacy

Due to new European legislation regarding how websites store information about you, AWIN is updating its privacy policy. You can see the new version of our policy here. If you would like to see the information we capture on this website, please click here for further details. In order to accept cookies on this site please click the 'I ACCEPT' button