Google Analytics

Send events from Dashly to your GA

This integration allows to set up the sending of "Chat opened", "Auto message received" and "Auto message reply left" events into Google Analytics.

This script can be inserted to "Configure the JavaScript code" field in Tracking master section.

The examples below can work incorrectly if GA is inserted via Google Tag Manager

Sending "Chat opened" event to GA:

// For GA:
dashly.addCallback('messenger_opened', function(data) {
    ga('send', 'event', 'Dashly', 'ChatOpened');
});

// For GTM:
dashly.addCallback('messenger_opened', function(data) {
    ga.getAll()[0].send('event', 'Dashly', 'ChatOpened');
});

Assume that you have an auto message with ID=1234 and reply type "Email left". You can find auto message ID in the search box of auto message report:

ga.png

Then you can send "PopupSeen" event to GA like this:

// For GA:
dashly.addCallback('conversation_opened', function(data) {
    if (data.message == 1234) {
        ga('send', 'event', 'Dashly', 'PopupSeen');   }
});

// For GTM:dashly.addCallback('conversation_opened', function(data) {
    if (data.message == 1234) {
        ga.getAll()[0].send('event', 'Dashly', 'PopupSeen');
    }
});

Script to send "LeftEmailInPopup" event:

// For GA:
dashly.addCallback('user_replied', function(data) {
    if (data.message == 1234) {
        ga('send', 'event', 'Dashly', 'LeftEmailInPopup');   }
});

// For GTM:
dashly.addCallback('user_replied', function(data) {
    if (data.message == 1234) {
        ga.getAll()[0].send('event', 'Dashly', 'LeftEmailInPopup');
    }
});

Insert this script if you need to send to GA the event about any message showing:

// For GA:
dashly.addCallback('conversation_opened', function(data) {
    if (data.message) {
      ga('send', 'event', 'Dashly', 'MessageSeen');
    } 
});
// For GTM
dashly.addCallback('conversation_opened', function(data) {
    if (data.message) {
     ga.getAll()[0].send('event', 'Dashly', 'MessageSeen'); 
    } 

How to send email statistics to Google Analytics

You can send lead's actions (such as opening an email) to Google Analytics and use this data for metrics. Let's see how you can do it.

1. Create goals in Google Analytics

2. Create a new message and follow the steps

Select trigger, Audience, Sending conditions. Move to Form and Content step and click on edit HTML email code.

038to.png

Paste the code:

<img src="http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXXX-YY&cid={{user['clientId']}}&t=event&ec=email&ea=open&el=recipient_id&cs=newsletter&cm=email&cn=11" />

Script components explanation:

<img src= we deceive the postal service by requesting to upload an image. In fact there is no image, the inserted address is GET request which sends information to GA. So when your email will try to send "an image" it means that it sends information to Google Analytics.

http://www.google-analytics.com/collect? This is API for Measurement Protocol. You need to add Tracking ID and goal information to the following parameters.

v=1 Protocol version (required)

tid = UA-XXXXXX-YY Tracking ID / Web Property ID (required)

cid = {{user['clientId']}} user ID (required)

In order to add user ID from Dashly just record Client ID in any our property and add it.

ga(function(tracker) { var clientId = tracker.get('clientId'); dashly.identify({'clientId': clientId}); })

Paste this script to Tracking - Tracking master - Configure the JavaScript code

t = event Tracking type

ec = email Event category

ea = open Event action

el = recipient_id Event label (optional);

cs = newsletter Campaign Source (optional)

cm = email Campaign Medium (optional)

cn = 111 Campaign Name (optional)

Example with added parameters:

3. Complete message creating and launch it.

From now on, when someone opens your email, the metrics will be recorded. You can check it in your report.

Powered by Dashly