This approach is recommended for users who wish to send additional data to that already captured by our tracker by default.

Custom Events

Datagran uses custom events to collection additional data. Our API provides a simple method called __dgTrack which accepts only two parameters (passed in this order)

As an example, the following code will trigger an event named ‘Visit GT 1m’. The payload being passed here is a simple JSON array, but the developer can pass any arbitrary JSON data here

<script>

var custom_event = {'Userid':'HelloWorld'};

_dgTrack('Visit GT 1m',custom_event);

</script>

Datagran eventually aggregates all these custom events at the user level and this data is used internally for various other products in the Datagran suite, in addition to being available to the customer as raw data downloads. Developers can use our API to send any arbitrary data as an event.

User identification

An important scenario in advanced implementation is to be able to identify users. This is done using a special custom event named Identify. For example, suppose that you want to capture the email of a user when he submits a form and then associate his cookie ID with this email. In order to do this, you will do something like this

<script>

dg_tracker.identify("MyCustomUser1");

</script>

OR

<script>

_dgTrack('identify', 'MyCustomUser1');