How to Implement the Transaction Tag?



AB Tasty lets you save the data related to transactions on your website (e.g., transaction amounts, payment methods, number of purchased items, average cart value, item price, etc.). 

This data is available in the reports of each campaign in the form of indicators or filters. Please refer to the Campaign report guide for further information.

The first thing to know about the transaction tag is that it is not a tag itself (as the generic tag can be) but rather a revenue tracker that must be placed on the order confirmation page.

To send transaction data to AB Tasty and display it in the reports, you need to add the transaction tag to your purchase confirmation page after the generic AB Tasty tag.

Please note that transactions will only be linked to campaigns the user has seen. 


There are two ways to implement the transaction tag: 

  • With the Transaction Tag Generator (medium level of complexity)
  • With the dedicated code (advanced level of complexity - a developer is needed)

Once the transaction tag is implemented on your website, you can go ahead and run the QA process. For further information, please refer to the FAQ about the transaction tag.

Option 1: The Transaction Tag Generator

(Medium level of complexity)


Transaction tag generator enables you to implement your transaction tag easily as you just need to indicate where to find the transaction data. The transaction tag will be automatically embedded in the generic tag with no need for creating or modifying any code. 




👉 Debugging is made easier since we have more visibility on what has been set up compared with a code you have to add to your source code or your TMS.

👉 The transaction tag generator is based on data layer variables or CSS selectors you have defined. These parameters are more stable than using a custom code. 

Heads up

👉 You must implement and find the exact variable names to make the transaction tag generator work.

👉 If the variables are modified on your website, it will also impact the transaction tag collection. You will need to adapt the transaction tag implementation accordingly.


When implementing the transaction tag directly in the settings, you do not need to implement it again into your source code.




You can implement your transaction tag using one of the three following methods:

👉Datalayer mode: by declaring the variables from your data layer containing the transaction-related information.

👉Selector mode: by declaring the CSS selectors containing the transaction-related information.

👉Expert mode: by completing the code snippet.


To use the data layer mode, you first need to integrate your data layer into your AB Tasty account settings.

Depending on the settings you specified, a JavaScript code is created and will be automatically included in the AB Tasty tag. This code is updated each time the configuration is modified and saved with the tag up-to-date.

First, you need to create an affiliation, which coincides with the name you will give to your transaction tag. 


Then, you must specify the URL(s) of your website on which the transaction information is available, such as the confirmation page. 




You can create as many affiliations as you want and you can edit and delete them.


You need to select the method with which you want to implement your transaction tag: 


Data Layer Mode


The data layer mode enables you to implement your transaction tag based on the variables defined in your data layer.

For each mandatory field, you need to enter the name of the key that will be extracted from the corresponding variable. These keys can be found in your data layer. 

For example, to fill in the transaction ID, you need to enter the key corresponding to the transaction ID you configured in your data layer. If the transaction is available in the key order_id with a corresponding value OD564, this means that you need to enter the order_id in the transaction ID field. 


Please note that the tag will try its best to automatically format your data to the correct data type, ie. transform a character string into a number, but some specific data conversion will not be possible. You should type in already formatted data rather than let the tag automatically convert them to avoid any issues. Please refer to this documentation for further information about expected data types.




For further information about the data layer, please refer to our integration guide


Selector Mode


The selector mode can be used if the transaction data is available directly in the code of your confirmation page. In this case, you need to fill in each field with the corresponding CSS selector that can be used in the document.querySelector function.


The item count number (icn) coincides with the total number of items purchased during the transaction. It can be calculated via three different methods.



"transaction_id": "transac1234",
"items_count": 5
"products": [
"name": "item 1",
"quantity": 2
"name": "item 2",
"quantity": 3


👉 If your key (data layer mode) or selector (selector mode) contains the total number of purchased items, select Default.

In the code example, the key would be items_count (returns 5)


👉 If your key or selector contains unitary purchased items, select Count.

In the code example, the key would be products[] (returns 2)

👉 If your key or selector contains the quantity of each purchased item, select Sum.

In the code example, the key would be products[].quantity (returns 5)


Expert mode

The Expert mode enables you to implement your transaction tag via a JavaScript code.
By default, there is a code example that you can edit and replace with your own data, available in your source code or Datalayer. You also need to apply the appropriate format to your values (string, float or integer) as described in our developer portal


The transaction affiliation/name (ta), transaction id (tid), transaction revenue (tr) and item count number (icn) must be declared during transaction tag implementation. The other settings are optional, however we recommend configuring them also in order to enable the application of matching filters in the reports later on. 


Adding Purchased Items Data


Information related to the purchased items can be linked to each transaction to apply matching filters in the campaign reports or to use purchase-related targeting criteria. 

Purchased items data can be collected via the three available methods: Datalayer, Selector, or Expert.


  • First, select Array of items as an optional value and enter the key or selector corresponding to the array of objects of all items purchased during the transaction.


In the above example, all item-related data are stored in the transactionProducts array of the data layer, on the purchase confirmation page.




  • Click Add optional value:
    All the data corresponding to items’ characteristics appear as additional fields where you can insert the data layer key or selector corresponding to the item name, price, quantity, ID, and category:



In this example, on the data layer, the item name can be found in the name key, the ID in the SKU key, and so on.




Expert mode

To add the purchased items data in the Expert mode, apply the following steps: 

  1. Complete the variable corresponding to “__TRANSACTION _ITEMS_ARRAY__”.
  2. Complete all the items characteristics with their corresponding variables in tid, in, ip, iq, ic and iv. 
    Array_code_2 (1).png



The preview enables you to verify that your transaction tag has been correctly configured by showing the latest transactions registered on your website.

The Transaction Tag Generator is using universal collect data. This is why, after you have implemented your transaction tag, it may take a few hours for the first transactions to be visible in the preview.


Once the new affiliation has been saved, do not forget to refresh the tag (in the header right) to be sure that all your modifications are taken into account in production.


For each transaction, the values corresponding to the keys you specified in your transaction tag are displayed:



If the preview is still empty after several hours, it probably means that one of the fields has not been implemented correctly. Please, check the URL page and all the fields again to be sure that everything is set up correctly. If not, you should ask your technical team or your dedicated AB Tasty consultant to do it for you. 

Option 2: A dedicated code

(Advanced Level of Complexity – A Developer is Needed)


You can create and code your transaction script you will then integrate into your confirmation page’s source code or your Tag Management System (e.g GTM or Tag Commander). 

The transaction tag features two parts: the first part enables the transmission of information related to the transaction (ID, name, amount, delivery fees, etc.) and the second part enables the transmission of item or product details related to purchases made by customers visiting your website.


Once you have implemented the transaction tag with one of the two methods explained in this article, you can verify that the data is well collected by reading our QA the transaction tag article



If you still have questions, you can visit our Frequently Asked Questions about the transaction tag. 

Was this article helpful?