Setting the ‘amtlist’ variable for Linkshare in Tealium

LinkShare is a leading provider of full-service online marketing solutions specializing in the areas of Affiliate Marketing, Search Marketing, and Lead Generation.

The Linkshare tag has a variable called ‘amtlist’ that is used to show the product-wise breakdown of the sale amount. It is an array whose length is set by the ‘qlist’ variable that stores the number of different products bought. Each value of amtlist should thus account for the numbers of that particular product bought. If 2 items of a product X and 1 item of product Y are bought, the array should have 2 cells with the first cell having twice the price of product X and the second cell with the price of a single item of product Y. In this example, we are using the local_product_unit_price of each product.

The Javascript code to assign value to amtlist should run before this tag is fired. For this, we need to create an extension of type Javascript Code. Here are the steps to follow to correctly populate the ‘amtlist’ variable of the Linkshare tag.

1. In the Tealium console we go to ‘Extensions’.

2. Click on the ‘+Add’ button next to ‘Javascript Code’.

3. Write a title – ‘Setting the amtlist Variable for Linkshare’.
4. In ‘Scope’, select the Linkshare tag whose data we are setting.

5. Create a new array – quantityaccounted_local_product_unit_price. The identifier ‘var’ should not be in front of that variable as that will limit it’s scope and it will not be visible to the tags.
6. Initialize variables to be used to hold values.
7. Write a ‘for’ loop to go through each product bought.
8. Within each loop convert the string value of local_product_unit_price[i] to a float value that is stored in the variable ‘cellprice’.
9. Get the quantity of that particular product from product_quantity[i] and assign it to a variable ‘cellquantity’.
10. Multiply cellquantity and cellprice to get the total sale amount contributed by this product.
11. Make adjustments to reflect the pre-tax sale amount, if needed.
12. Enter this value into the new array.
13. This way the new array created has the tax-and-quantity-adjusted sale amount for each product bought.
14. We now need to point the amtlist variable to this array. For this, we go to Tags and click on the Linkshare tag.
15. Click on Edit button next to Mapped Data Sources.
16. Click on the dropdown next to Data Sources and select quantityaccounted_local_product_unit_price.
17. Click on Select Destination and select amtlist and click on Apply.

18. Once the changes are saved, we can check by making a purchase and checking the amtlist value in the data passed by the Linkshare tag. The cell values are separated by a pipe symbol.
19. Note: Always test javascript code in a local file with values supplied to variables. When we are sure it works, it makes sense to upload it into an extension.

Tealium Expert



More from our blog

See all posts