Data tracking via JS API

Track user events that and properties from your website

Find full description of JavaScript API in the Developers section.

To paste JS code, move to Tracking -> Tracking master -> Configure the JavaScript code and click "Start". You will see a field for code inserting.

You can find a code example for the most common cases of JS API data tracking below. Don't forget that this is only a part of the possibilities.

You will have to add this code to Tracking -> Tracking master -> Config

Record last UTM tags

Dashly records first UTM parameters to lead properties by default. If you want to record all further UTM parameters, add 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] });

Record a phone number from a masked field

Example: we have a field with #USER_PHONE selector. The principle is the following: when focus on a field is lost (lead finishes to fill in and clicks somewhere else), then method identify will work and record information to a lead's card.

This code in JavaScript:

document.querySelector('#USER_PHONE').onblur = function() {

  dashly.identify([{op: 'update_or_create', key: '$phone', value: this.value}])


Add page URL to event property

Move to Tracking -> Tracking master -> Configure the JavaScript code and enter the following code:

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

The code in the section should look like this. Do not forget to save.

Now you can use #curl selector for entering to event properties and lead's properties.

Add URL to leads' property

You need to use the identify method.

Example. Record of last visited page.

Enter the following script in Tracking -> Tracking master -> Configure the JavaScript code:

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