This tagging guide is designed for advanced users.



Our library works with triggers that generate specific types of processing, according to predefined events. The library gives default access to a set of contextual data sent when specific events are triggered, and provides advanced users with a customised event management system. The advanced user can also link a callback function to a trigger executed when an associated event occurs.


Trigger format

A trigger is a name/label made up of a group of fields (levels or categories), separated by a colon (” : “).



In this example, the trigger is defined at the Tracker level and is executed after a hit is successfully sent.

It is technically possible to connect to this event to potentially trigger actions. Detailed information, such as the value of the hit at the time of sending, is automatically added when the trigger is executed.


Listening to a trigger

The Tracker has an “onTrigger()” method allowing you to listen to a trigger. This method takes three parameters:

  • trigger : Name of the trigger to which you want to listen; mandatory.
  • callback : Method you wish to execute.
  • singleUse : If you want to call the callback method just once, or at each event trigger (“true” or “false”; “false” by default).

To listen to a specific trigger, you must know its exact value.

Example with a page tag:

Example of data added in the console by the custom “callback()” method:

You may listen to a list of triggers belonging to the same category.

Example of triggers that belong to the same category:

Here, we have two triggers, fired respectively, when the hit was successfully sent, or when the hit failed (network error, etc.).
The trigger management system enables you to listen to a list of triggers belonging to the same category, by using the special character ” * “.

In this example, listening to the trigger ‘Tracker:Hit:Sent:*’ lets you add information in the console in order to know if the hit has been correctly sent, or if there was an error.

By extension, you can listen to all triggers by directly using ” * ” as a name/label.


Creating a trigger

The Tracker has an “emit()” method allowing a trigger to be generated. This method takes two parameters:

  • trigger: Name of the trigger to emit; mandatory.
  • data: Data you wish to transmit.

Full example with a page tag (using the “emit()” and “onTrigger()” functions):

Example of data added to the console by the custom “callback()” method:


Existing triggers



By default, our library generates a series of triggers that provide a set of data related to the specific context of execution, and to which you can listen.

Certain triggers are only accessible in the debug version of SmartTag.

Triggers can have a technical origin, meaning they can be directly related to the Tracker‘s functioning.

  • Each helper (plugin tagging method) creates a trigger according to the format ‘[PluginName]:[Object]:[Helper]‘.
  • Certain tagging values are verified, and errors can be flagged in cases where they don’t match the expected format. A trigger in the format ‘[PluginName]:[Object]:[Helper]:[Property]:Error‘ will be detected.
  • Certain plugins proceed with tagging verification when the hit is sent by the “dispatch()” method. They generate triggers in the format ‘[PluginName]:onDispatch:Error‘ in cases where an error or a warning is detected. The plugins in question are NuggAdSalesTracker and TvTracking.
  • Certain plugins send detailed information when they are initialised, via a trigger in the format ‘[PluginName]:Ready‘. This is notably the case with the plugins ClientSideUserIdContextVariablesIdentifiedVisitorInternalSearchOffline and OnSiteAds.

List of triggers by feature


Was this post helpful?
Last update: 30/01/2018