Custom event tagging

This guide is only available for Analytics Suite Delta analysis

 

Foreword

The Tracker has technical methods for tagging events useful to complete the basic functionality of the SDK.

These methods are available for SDKs:

  • JavaScript from version 5.21.0
  • Android from version 2.17.0
  • Apple from version 2.18.0
 

Tagging methods

The Tracker features functions to send custom events:

  • tag.events.send for an independent sending of an event
  • tag.events.add and tag.dispatch for grouped sending of an event with other tags
  • tracker.events.add and tracker.dispatch for grouped sending of an event with other tags
  • tracker.Events().add and tracker.dispatch for grouped sending of an event with other tags
 

send

events.send(name, data, options)

Sending an event independently.

ParamTypeDescription
namestringName of the event
dataobjectContent of the event
optionsobjectTechnical configuration elements of the Tracker for sending

The parameter options allows to declare useful properties for the automatic management of clicks or for the automatic execution of a method after sending the hit.

It therefore accepts three properties such as:

  • elem corresponding to the tagged DOM element
  • event corresponding to the click event
  • callback corresponding to a custom function to be executed after sending

Tagging example

tag.events.send('product.display',
     {
        'placement': 'homepage_slider',
        'product': {
            'id': 'id1',
            'name': 'name1',
            'brand': 'brand1',
            'original_price': 16.50,
            'price': 14.00,
            'currency': 'EUR',
            'stock': true,
            'category1': 'category1',
            'category2': 'category2',
            'position': 1
        }
     },
     {
        elem: this, // (optional) Tagged DOM element
        event: event, // (optional) JavaScript event (prevent event propagation)
        callback: callback // (optional) function to execute
     });


No equivalence.


No equivalence.

 

add / dispatch

events.add(name, data)

Add an event for a grouped sending.

ParamTypeDescription
namestringName of the event
dataobjectContent of the event

Tagging example

tag.page.set({'name': 'homepage'});
tag.events.add('product.display',
     {
        'placement': 'homepage_slider',
        'product': {
            'id': 'id1',
            'name': 'name1',
            'brand': 'brand1',
            'original_price': 16.50,
            'price': 14.00,
            'currency': 'EUR',
            'stock': true,
            'category1': 'category1',
            'category2': 'category2',
            'position': 1
        }
     });
tag.dispatch();
events.add(name, data)

Add an event for a grouped sending.

ParamTypeDescription
nameStringName of the event
data[String : Any]Content of the event

Tagging example

tracker.screens.add("homepage")
_ = tracker.events.add(name: "product.display", data:
[
    "placement": "homepage_slider",
    "product":
    [
        "id": "id1",
        "name": "name1",
        "brand": "brand1",
        "original_price": 16.50,
        "price": 14.00,
        "currency": "EUR",
        "stock": true,
        "category1": "category1",
        "category2": "category2",
        "position": 1
    ]
])
tracker.dispatch()
Events().add(name, dataObject)

Add an event for a grouped sending.

ParamTypeDescription
nameStringName of the event
dataObjectMap<String, Object>Content of the event

Tagging example

tracker.Screens().add("homepage");
tracker.Events().add("product.display", new HashMap<String, Object>() {{
	put("placement", "homepage_slider");
	put("product", new HashMap<String, Object>() {{
	    put("id", "id1");
	    put("name", "name1");
	    put("brand", "brand1");
	    put("original_price", 16.50);
	    put("price", 14.00);
	    put("currency", "EUR");
	    put("stock", true);
	    put("category1", "category1");
	    put("category2", "category2");
	    put("position", 1);
    }});
}});
tracker.dispatch();
 

Cet article a-t-il été utile ?

Last update: 10/08/2020