How to use the Transaction Tag Generator

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. 

Benefits

πŸ‘‰ 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.

Configuration

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. 

How_to_Implement_the_Transaction_Tag_01.png

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

How_to_Implement_the_Transaction_Tag_02.png

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.

How_to_Implement_the_Transaction_Tag_03.png

For further information about the data layer, please refer to this article.

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.

Example:

{
"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.

How_to_Implement_the_Transaction_Tag_04.png

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

How_to_Implement_the_Transaction_Tag_05.png

  • 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:

How_to_Implement_the_Transaction_Tag_06.png

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.

How_to_Implement_the_Transaction_Tag_07.png

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

Preview

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:How_to_Implement_the_Transaction_Tag_08.png

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. 

Was this article helpful?

/