Piano Analytics SDK
With the Piano Analytics SDK, you can tag custom properties without using a specific method as the "tag first" approach is used.
You can tag your custom properties as in the example below :
pa.sendEvent('page.display', {
'page':'pagename',
'custom_prop':'value'
})
However, if you need to send this property on several events of the same page, then you can use the pa.setProperty method.
This method allows adding a persistent notion to your properties.
pa.setProperty('custom_prop', 'value', {
'persistent':true
});
pa.sendEvent('page.display', {
'page':'pagename'
})
The persistent parameter can take as a value "true" which allow adding this custom property to all subsequent events of the page. If this parameter take "false" as value, only the next event after this method will take the custom property.
You can define which events are going to be filled with the custom property with the events parameter.
pa.setProperty('custom_prop', 'value', {
'persistent':true,
'events': ['page.*', 'click.navigation']
});
In the example above, only the events beginning with "page." and "click.navigation"events will be filled with the property "custom_prop".
If you want to send a list of properties you can use the pa.setProperties method.
Smarttag
The persistence notion is also available with the smarttag by using the setProp method or the setProps one if you need to send several properties.
You will find an example with the setProp method below:
var tag = new ATInternet.Tracker.Tag();
tag.page.set({
name:'Article'
});
tag.setProp("article_ID": "1", true); // Persistent
tag.dispatch();
In the example above, all the hits of the page will be enriched with the property "article_ID" with the value "1" as the persistent parameter is set to "True".
This method do not allow chosing a specific event to send the properties, unlike the Piano Analytics SDK with the “event” parameter.