Wiki:Users
From Wiki
Product Level Tracking (PLT) im Google Tag Manager (GTM)
The Product Level Tracking can also be used to provide publishers with additional information on shopping basket content/order details for optimisation purposes.
If an advertiser uses GTM for Awin tracking code playout, product level tracking can also be added quite easily. The prerequisite is an integrated enhanced e-commerce datalayer, see GA Enhanced Ecommerce UA or GA4 ecommerce measurement
GA Enhanced Ecommerce UA oder 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:
As well as the TransactionId or Order Reference:
GTM example code (GA4) for Awin PLT - Variant 1
Awin Product-Line specification:
AW:P|{{advertiserId}}|{{orderReference}}|{{productId}}|{{productName}}|{{productItemPrice}}|{{productQuantity}}|{{productSku}}|{{commissionGroupCode}}|{{productCategory}}
As "productId" and "productSku" are not available in this form, item_id is used here. Of course, a different ID can also be transferred if separate values are available 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 must be changed to customHTML tag or the following part must also be called as customHTML tag in parallel to 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 sample code (GA4) for Awin PLT - variant 2
Search for Awin in the GTM Tag Template Gallery and add it:
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; }
The array should then be used in the tag:
GTM example dataLayer Universal Analytics
<script>
<script> // Send transaction data with a pageview if available // when the page loads. Otherwise, use an event when the transaction // data becomes available. dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. dataLayer.push({ 'ecommerce': { 'purchase': { 'actionField': { 'id': 'T12345', // Transaction ID. Required for purchases and refunds. 'affiliation': 'Online Store', 'revenue': '35.43', // Total transaction value (incl. tax and shipping) 'tax':'4.90', 'shipping': '5.99', 'coupon': 'SUMMER_SALE' }, 'products': [{ // List of productFieldObjects. 'name': 'Triblend Android T-Shirt', // Name or ID is required. 'id': '12345', 'price': '15.25', 'brand': 'Google', 'category': 'Apparel', 'variant': 'Gray', 'quantity': 1, 'coupon': '' // Optional fields may be omitted or set to empty string. }, { 'name': 'Donut Friday Scented T-Shirt', 'id': '67890', 'price': '33.75', 'brand': 'Google', 'category': 'Apparel', 'variant': 'Black', 'quantity': 1 }] } } }); </script>
The product array (products) should be created as a variable:
As well as the TransactionId or Order Reference:
GTM sample code (UA) for Awin PLT - Variant 1
AW:P|{{advertiserId}}|{{orderReference}}|{{productId}}|{{productName}}|{{productItemPrice}}|{{productQuantity}}|{{productSku}}|{{commissionGroupCode}}|{{productCategory}}
As "productId" and "productSku" are not available in this form, product-"id" is used here. Of course, a different ID can also be transferred 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.purchase.products}}; var awin = ""; for (i = 0; i < productArray.length; i++) { awin += 'AW:P|1001|' +{{dlv - ecommerce.purchase.actionField.id}}+'|' +productArray[i].id+'|' +productArray[i].name+'|' +parseFloat(productArray[i].price).toFixed(2)+'|' +productArray[i].quantity+'|' +productArray[i].id+'|' +'Default|' +productArray[i].category + "\r\n"; } return awin; }
If the conversion tag from the tag templates has been used, either the entire tag must be changed to customHTML tag or the following part must also be called as customHTML tag in parallel to 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 sample code (UA) for Awin PLT - variant 2
Search for Awin in the GTM Tag Template Gallery and add it:
Next, as before, the dataLayer with the transactionProducts should be available. Using the "products" 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.purchase.products}}.length; i++) { awinProductArray.push({ 'id' : {{dlv - ecommerce.purchase.products}}[i].id, 'name' : {{dlv - ecommerce.purchase.products}}[i].name, 'price' : {{dlv - ecommerce.purchase.products}}[i].price, 'quantity' : {{dlv - ecommerce.purchase.products}}[i].quantity, 'sku' : {{dlv - ecommerce.purchase.products}}[i].id, 'cGroup' : 'DEFAULT', 'category' : {{dlv - ecommerce.purchase.products}}[i].category }) } return awinProductArray; }