Developers » Piano Analytics tagging » Event tagging » Send events
Send events
This guide is only available for Piano Analytics analysis
Please check the compatibility table
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 eventtag.events.add
andtag.dispatch
for grouped sending of an event with other tags
tracker.events.add
andtracker.dispatch
for grouped sending of an event with other tags
tracker.Events().add
andtracker.dispatch
for grouped sending of an event with other tags
send
events.send(name, data, options)
Sending an event independently.
Param | Type | Description |
name | string | Name of the event |
data | object | Content of the event |
options | object | Technical 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 elementevent
corresponding to the click eventcallback
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.
Param | Type | Description |
name | string | Name of the event |
data | object | Content 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.
Param | Type | Description |
name | String | Name 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.
Param | Type | Description |
name | String | Name of the event |
dataObject | Map<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();