Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Adobe DTM: Setting up 3rd Party Conversion tags

pauld46525055
Level 1
Level 1

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

1 Accepted Solution
ParitMittal
Correct answer by
Level 10
Level 10

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

View solution in original post

2 Replies
ParitMittal
Correct answer by
Level 10
Level 10

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

View solution in original post

jantzen_belliston-Adobe
Community Manager
Community Manager

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