Data tracking via JS API

Track user events and properties from your website

You can find the full description of the Dashly JavaScript API in the Developers section.

To use a JS code, move to the “Settings” – “Visitors data tracking” –  “Configure the JavaScript code” section and. There, you will see a field for code inserting. You can paste your JS code in that field.

You can find code examples for the most common cases of JS API data tracking below, but don't forget this is only a fraction of the JavaScript possibilities.

Record last UTM parameters

Dashly records first UTM parameters to lead properties by default. If you want to record UTM parameters that may be recorded in a user’s user card further, use the following code:

function TrackUtm(){
var utm_sorce = window.location.href.match(/utm_source=([^&]+)/);
var utm_medium = window.location.href.match(/utm_medium=([^&]+)/);
var utm_campaign = window.location.href.match(/utm_campaign=([^&]+)/);
var utm_term = window.location.href.match(/utm_term=([^&]+)/);
var utm_content = window.location.href.match(/utm_content=([^&]+)/);
if (utm_content != undefined) {
dashly.identify({ 'Last UTM Content': utm_content[1] });
}
if (utm_sorce != undefined) {
dashly.identify({ 'Last UTM Source': utm_sorce[1] });
}
if (utm_medium != undefined) {
dashly.identify({ 'Last UTM Medium': utm_medium[1] });
}
if (utm_campaign != undefined) {
dashly.identify({ 'Last UTM Campaign': utm_campaign[1] });
}
if (utm_term != undefined) {
dashly.identify({ 'Last UTM Term': utm_term[1] });
}
}
 
TrackUtm();

Add page URL to event property

Move to “Settings” – “Visitors data tracking” – “Configure the JavaScript code” and enter the following code:

$('body').prepend('<input type="hidden" value="' + window.location.href + '" id="curl">');

Now you can use the #curl selector for recording event property and user property value containing the URL to the current website page.

Add URL to leads' property

Example. Recording the last visited page.

Enter the following script in "Settings" – "Visitors data tracking" – "Configure the JavaScript code":

dashly.identify([{op: 'update_or_create', key: 'Last visited page', value: window.location.href}]);
Powered by