Basic steps for SaaS data tracking

Explore how to deal with it

Step 1. Auto tracking deactivation

The system automatically tracks emails from all fields on your website. Once lead enters a new email, the new email will be added.

Go to Tracking -> Tracking master -> Auto tracking and disable email tracking.

 

Step 2. Transfer User ID

We use User ID to combine leads with different devices. As soon as one logs in you need to transfer his User ID to us via this command:

dashly.auth('25', 'hmac-sha256-hash');

The first argument is the User ID. The second is HMAC SHA 256 hash (the hashing text is User ID, the key is User Auth Key, you can find it in the admin panel).

Example in PHP:

$userId = '...';

$hash = hash_hmac('sha256', $userId, 'User-Auth-Key' );

echo "dashly.auth('".$userId."', '".$hash."')"

 

Step 3. Lead properties and actions transfer

An event is a lead action on your website (contacts page visiting, scrolling to the bottom, clicking on a button, filling in input field, subscribing, etc). Once such event happens, it should be immediately sent to Dashly.

You can do it via JS API methods:

// No parameters

dashly.track('Event name');

// With parameters

dashly.track('Event name', {

  param1: 'value1',

  param2: 340,

  param3: '2014-05-23T05:12:45',

  param4: false,

  param5: ['key1', 'key2', 'key3']

});

Web API methods:

// No parameters

curl -X POST \

  --data-urlencode "event=Order Created" \

  --data-urlencode "auth_token=XXX" \

  https://api.dashly.io/v1/users/{id}/events

// With parameters

curl -X POST \

  --data-urlencode "event=Order Created" \

  --data-urlencode 'params={"item": "chicken"}' \

  --data-urlencode "auth_token=XXX" \

  "https://api.dashly.io/v1/users/{id}/events"

ID is User ID in Dashly (User ID is in dashly_uid cookie). You can use your User ID as well if you have configured leads bonding.

 

JS API and Web API methods can be used as well to configure lead properties (identification).

JS API example:

// Simplified format:

dashly.identify({'$name': 'Maks', myProp: 'myValue'});

// Complex format:

dashly.identify([

  {op: 'add', key: 'segment1', value: 1},

  {op: 'update_or_create', key: 'segment2', value: 1},

]);

 JS API example:

curl -X POST \

  --data-urlencode "operations=[{"op": "update_or_create", "key": "$name", "value": "Maks"}]" \

  --data-urlencode "auth_token=XXX" \

  https://api.dashly.io/v1/users/{id}/props

 

Step 4. Importing leads to Dashly

You can import your database to our system via Web API (More about API)

Example in PHP:

# List of the leads you need to import

# The first element is the User ID from your system

$users = array(

              array('id' => 123,

                              'email' => 'mail1@mail.ru',

                              'phone' => '891xxxxxx',

                              'name' => 'Test'

              ),

              array('id' => 456,

                              'email' => 'mail2@mail.ru',

                              'phone' => '891xxxxxx',

                              'name' => 'Test2'

              )

);

$auth_token = 'xxx' # TODO: ADD YOUR AUTH_TOKEN HERE, you can find it in Settings - API keys

 

for ($i =0; $i < count($users); ++$i ) {

              $url = 'http://api.dashly.io/v1/users/'.$users[$i]['id'].'/props?auth_token='.$auth_token;

              $operations = json_encode(array(

                                           array('op' => 'update_or_create',

                                                           'key' => '$email',

                                                           'value' => $users[$i]['email']

                                           ),

                                           array('op' => 'update_or_create',

                                                           'key' => '$phone',

                                                           'value' => $users[$i]['phone']

                                           ),

                                           array('op' => 'update_or_create',

                                                           'key' => '$name',

                                                           'value' => $users[$i]['name']

                                           ),

                            )

              );

             

              $result = file_get_contents($url, false, stream_context_create(array(

                'http' => array(

                            'method' => 'POST',

                            'header' => 'Content-type: application/x-www-form-urlencoded',

                            'content' =>http_build_query(array('operations' => $operations,'by_user_id' => 'true')),

                )

              )));

              print $result;

}

Powered by Dashly