Adobe DTM: Setting up 3rd Party Conversion tags | Community
Skip to main content
June 14, 2017
Solved

Adobe DTM: Setting up 3rd Party Conversion tags

  • June 14, 2017
  • 2 replies
  • 1547 views

I have been using various tag managers(Tealium & GTM) over the past 6 years. Recently, I've had a client that started using Adobe DTM. I am not a javascript programmer so this tool is far too technical for me.

The challenge I'm having is converting marketing vendors static code into workable code in DTM that will allow for the digitalData's array format when it comes to multiple products.

Are there any resources that show how to convert single product script into one that assesses an array and then provides values a, b, c & d for each instance of the array?

Example: i would want to be able to capture product ID, sku, quantity & price for each array item

digitalData.transaction.item[0]

digitalData.transaction.item[0].productID

digitalData.transaction.item[0].SKU

digitalData.transaction.item[0].quantity

digitalData.transaction.item[0].price

digitalData.transaction.item[1]

digitalData.transaction.item[1].productID

digitalData.transaction.item[1].SKU

digitalData.transaction.item[1].quantity

digitalData.transaction.item[1].price

Original marketing pixel code provided:

var trans = {

    orderid : 'ORDERID', /*not an array item */

    currency: 'CURRENCYCODE', /*not an array item */

    customerStatus: 'CUSTOMER_STATUS', /*not an array item */

    conversionType: 'Sale', /*not an array item */

    customerID: 'CUSTOMER_ID', /*not an array item */

    discountCode: 'DISCOUNT_CODE', /*not an array item */

    discountAmount: DISCOUNT_AMOUNT, /*not an array item */

    taxAmount: TAX_AMOUNT, /*not an array item */

    lineitems : [{

        quantity : QUANTITY_PURCHASED, /*found in array */

        unitPrice : SINGLE_UNIT_ITEM_PRICE, /*found in array */

        SKU: 'PRODUCT_SKU', /*found in array */

        productName: 'PRODUCT_NAME' /*found in array */

    }]

};

I know that all of the lineitem values will need to go through a conditional statement that looks for the value of the array and apply the 4 items, increment the array value and continue until there are no other array values. I just don't know how to program that since I don't know javascript

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParitMittal

Hi Paul ,

Assuming that the Jason structure is like below as per my understanding:

var trans = {

    orderid : 'ORDERID', /*not an array item */

    currency: 'CURRENCYCODE', /*not an array item */

    customerStatus: 'CUSTOMER_STATUS', /*not an array item */

    conversionType: 'Sale', /*not an array item */

    customerID: 'CUSTOMER_ID', /*not an array item */

    discountCode: 'DISCOUNT_CODE', /*not an array item */

    discountAmount: DISCOUNT_AMOUNT, /*not an array item */

    taxAmount: TAX_AMOUNT, /*not an array item */

    lineitems : [{

        quantity : QUANTITY_PURCHASED,

        unitPrice : SINGLE_UNIT_ITEM_PRICE,

        SKU: 'PRODUCT_SKU',

        productName: 'PRODUCT_NAME'

    },

{

        quantity : QUANTITY_PURCHASED,

        unitPrice : SINGLE_UNIT_ITEM_PRICE,

        SKU: 'PRODUCT_SKU',

        productName: 'PRODUCT_NAME'

    }

]

};

The javascript code would be like below:

   for (var i = 0; i < trans.lineitems.length; i++) {
var quantity = trans.lineitems[i].quantity;

var price = trans.lineitems[i].unitPrice;

var sku = trans.lineitems[i].SKU;

var productname = trans.lineitems[i].productName;
  alert
(quantity + ', ' + price + ', ' + sku +','+ productname);
  
}

Regards

Parit Mittal

2 replies

ParitMittal
ParitMittalAccepted solution
Level 10
June 15, 2017

Hi Paul ,

Assuming that the Jason structure is like below as per my understanding:

var trans = {

    orderid : 'ORDERID', /*not an array item */

    currency: 'CURRENCYCODE', /*not an array item */

    customerStatus: 'CUSTOMER_STATUS', /*not an array item */

    conversionType: 'Sale', /*not an array item */

    customerID: 'CUSTOMER_ID', /*not an array item */

    discountCode: 'DISCOUNT_CODE', /*not an array item */

    discountAmount: DISCOUNT_AMOUNT, /*not an array item */

    taxAmount: TAX_AMOUNT, /*not an array item */

    lineitems : [{

        quantity : QUANTITY_PURCHASED,

        unitPrice : SINGLE_UNIT_ITEM_PRICE,

        SKU: 'PRODUCT_SKU',

        productName: 'PRODUCT_NAME'

    },

{

        quantity : QUANTITY_PURCHASED,

        unitPrice : SINGLE_UNIT_ITEM_PRICE,

        SKU: 'PRODUCT_SKU',

        productName: 'PRODUCT_NAME'

    }

]

};

The javascript code would be like below:

   for (var i = 0; i < trans.lineitems.length; i++) {
var quantity = trans.lineitems[i].quantity;

var price = trans.lineitems[i].unitPrice;

var sku = trans.lineitems[i].SKU;

var productname = trans.lineitems[i].productName;
  alert
(quantity + ', ' + price + ', ' + sku +','+ productname);
  
}

Regards

Parit Mittal

jantzen_b
Adobe Employee
Adobe Employee
July 21, 2017

Did Parit's reply help you to find a solution to your question? If so, I'd like to mark it correct.