Creating a Custom Tracking via the DataLayer

The Goal management page enables you to create Custom Trackings directly linked to the DataLayer you have implemented in AB Tasty. These Custom Trackings can then be used to create metrics based on your DataLayer data.


To create a custom tracking for your DataLayer:

  1. From the Goal Management page (Settings > Account > Goal Management), go to the Custom Tracking tab.
  2. Click Create Custom Tracking on the top right of the table.
  3. Select From a DataLayer.



Tracking the value of a key in your DataLayer

The custom tracking will be fired when a field, specified by you, matches a certain condition.These are the steps:

  1. Giving the custom tracking variable a name. This name can be anything you choose and only aims at helping you recognise what you create.
  2. The “key” is the name of the field you want to track in your DataLayer
  3. The dropdown menu contains a list of operators that allows you to check for the state or value of the field in the DataLayer. The list of operators:
Operator Description
Equals Real key value = Target value
Does not equal Real key value ≠ Target value
Is lower than Real key value < Target value. This has to be a numerical value.
Is higher than Real key value > Target value. This has to be a numerical value.
Is included between Upper Target value > Real key value > Lower Target value.
These have to be numerical values.
Contains Example: the value “homeowner” contains “meow”. That will trigger the tracking. This is mainly for string data types.
Is declared The key exists in the DataLayer. This does not need a value.
Is not declared The key does not exist in the DataLayer. This does not need a value
  1. Select the value of the key that would trigger the Custom Tracking:
    Each time the value will match your rule, an event will be fired via our tag Datacollect.

An example is given in the image below:

It means that, once saved, the custom tracking will be triggered when the DataLayer has a field “event” having a value of exactly “gtm.load”.
The final steps are to Save the custom tracking, and reload your tag.


Tracking the value of nested keys in your DataLayer

The DataLayer typically will not have a single level of key:value pairs. It may have nested keys, like in a typical object.
In the previous section, the key:value pair was a first level pair.

You may want to track a 2nd level or even 3rd level key:value pair, like in the image below:

To track nested keys like “pagetype” or “type”, the key field in the custom tracking creation modal can be input with dots (.) as shown:

  • page.pageType - this will have a value of “HOME”
  • page.device.type - this will have a value of “mobile”


💡 Good to know

Arrays are not handled in the DataLayer for the moment, but only objects and subobjects.


Tracking a combination of key:value pairs

It is possible to have a custom tracking triggered by several conditions being true. Taking the last examples in the previous section, the custom tracking will be triggered if “page.pageType” is equal to “HOME” only.
The Custom tracking can also be triggered by BOTH “page.pageType” = “Home” AND “page.device.type” = “mobile”. To do this, create a custom tracking and click on “Add condition”. This will show a second row of inputs to specify another condition.

Notice the new dropdown which appeared “Matching all following conditions”. This means that both (or all, in case there are more than 2) conditions need to be true for the tracking to be triggered. If only 1 is true, the tracking will not be triggered. If none are true, it will also not be triggered.

This dropdown has another option of “some”. This means that at least 1 condition needs to be true for the tracking to be triggered. If both are true, it will also be triggered. If none are true, it will not be triggered.


Good to Know 💡

The "all" condition means that all the specified criteria need to be met across every part of the dataLayer, not just in one event. If an event doesn’t match all the conditions, we’ll check if the other events do match the rest of the conditions mentioned.

Important Note:

Once again, once the custom tracking is created and saved, do not forget to refresh your tag.


Using the custom tracking

Once custom trackings are created, they can be used as goals for your reporting. To include them in your Reportings:

  1. Go to the goal step of your campaign
  2. Shoose “Custom Trackings”
  3. In the middle pane, you should see the custom tracking you created with the name you gave them (see first section)
  4. You can then drag and drop them as primary or secondary goals from here.
  5. Save.

Good to Know 💡- When is the custom tracking triggered?

The DataLayer is a global array which is displayed when one website is also loaded. When a user makes any action on the website, some new items could be pushed inside this array. That’s why the DataLayer could grow up. Once you’ve finished setting up one or several custom trackings on app2, we are able to detect if the association key:value is already inside the DataLayer or if it is inside a new pushed item. 

Was this article helpful?