Triggered JavaScript

Auto message "Launch Java Script in the lead's browser" is aimed at running triggered scripts in the lead's browser.

This message type can help you with the following:

  • Show a pop-up with unique design;

  • Social media retargeting;

  • Track events in Google Analytics;

  • Insert forms into site;

  • Personal references in text of your site, etc.

Many other tasks can be done. Everything is limited by your fantasy.

 

Configuration

Let's see how to configure triggered JavaScript in browser:

Go to Auto -> Auto messages. Click "Create auto message".

  1.  Choose the trigger

Choose the trigger (event) which will initiate JS sending.

Important: With several triggers the message will be sent if ANY trigger works.

Choose a sending timeout after the event is completed: right after the event is completed, or after a time lag.

Set when the message will be sent: at any time or only at a particular period of time.

For example, 

wk3lp.png

  1.  Audience

Then you can limit the audience who will see the auto message. You may not be going to address every lead who performed the trigger event.

On Audience step, select leads you are going to send this message to. 

Show to leads who satisfy filters

"All" equals to logical "AND". In other words, all conditions must be met.

"Any" equals to logical "OR". In other words, if one filter (or all of them) is met, the lead will match.

Lead properties

Indicate properties leads must satisfy.

Lead events

Events done by the lead before triggered event.

Important: If an auto message has a delay in sending (you may set it on "Choose the trigger" step), then events and properties will be reviewed after this time period: triggered action - N-time period - lead filters are checked.

Important: If you have a saved segment, then you don't have to select lead properties and events. Just click on the segment, and its conditions will be automatically applied here. 

For example,

krv40.png

  1.  Sending conditions

Select resending condition: send the message only once, or resend it if a lead fulfills all conditions again, after N-time period.

For example,

wsu7t.png

  1.  Form and content

Select form and content of your message (chat, pop-up, email, etc).

Select "Additional types" and then find "JavaScript".

Enter JS code in the input field. Script can do anything: add and delete items on your site, run pop-up with unique design, etc.

For example,

v60zn.png

  1.  Goal

Select a goal you want to achieve via this message. Read more about goals in this article.

4qfk2.png

  1.  Review and launch

Check your settings and enter the name of this auto message. You can also indicate events for a message chain.

While creating JS pop-ups you may face issue with transferring statistics of reading, answering and clicking on a link in the pop-up. How to transfer this data? How to make Dashly understand that lead read/replied/followed a link in this particular pop-up?

You can do it with a couple lines of code.

Example: you have a pop-up with email response type ("email" id) and link ("link" id).

In order to track "read" event, add the following code into pop-ups code:

dashly.trackMessageInteraction('{{ sending_id }}', 'read');

Note that this code line should be added after a link to the page.

The event "Communications: Message read" will be added to the lead card, and +1 "read" metrics in mailing statistics tab will be added as well.

Track "replied to the auto message" event:

document.getElementById(“email”).onblur = function() { //Will cause the response event  after the lead has withdrawn the focus from the field

dashly.trackMessageInteraction('{{ sending_id }}', 'replied');

};

The event "Communication: Replied to the message" will be added to the lead card, and you will be able to check response statistics in campaign report.

Add this code in order to track "Followed a link in the message" event:

document.getElementById(“link”).onclick = function() {

dashly.trackMessageInteraction('{{ sending_id }}', clicked);

};

"Communications: Followed a link in the message" event will be added to lead card, you will be able to see this event metrics in campaign report.

Here is a pop-up example with "message read", "replied to the message" and "followed a link in the message" events.

var str = '\
        <style>\
            #cq-popup {\
                width: 700px;\
                height: 350px;\
                z-index: 23;\
                left: calc(50%);\
                top: calc(50%);\
                position: fixed!important;\
                padding: 60px 40px 60px 40px;\
                background-repeat: no-repeat;  \
                background-position: right;\
                background-color: #fff;\
                font-family: Open Sans, sans-serif;\
                transform: translate(-50%, -50%) scale(1);\
            }\
            #cq-popup h3 {\
                font-size: 40px;\
                padding: 0;\
                width: 500px;\
                float: left;\
                text-align: left;\
                margin-bottom: 10px;\
            }\
            #cq-popup > div {\
                width: 500px;\
                font-size: 27px;\
                line-height: 36px;\
            }\
            #cq-popup-btclose {\
                text-decoration: none;\
                font-size: 29px;\
                position: absolute;\
                right: 10px;\
                top: 0px;\
            }\
            #cq-popup-bg {\
                cursor: pointer;\
                position: fixed;\
                top:0; \
                width: 100%; \
                height: 100%;\
                background: rgba(51,51,51,0.8);\
                z-index: 22;\
            }\
        </style>\
       <div id="cq-popup-bg"></div>\
            <div id="cq-popup">\
              <a id="cq-popup-btclose">×</a>\
              <h3>\
                Hello\
              </h3>\
              <div>Hello world!</div>\
              <a href="https://example.com" id="cq-link">Link example</a>
              <input id="cq-popup-js-input" type="email" placeholder="ENTER YOUR EMAIL">
            </div>\
        </div>\
      ';
 
//Add pop-up to your page
var div = document.createElement('div');
div.innerHTML = str;
document.body.appendChild(div);
 
//Track message read event. "Communication: Message read" event will appear in lead card
dashly.trackMessageInteraction('{{ sending_id }}', 'read');
 
//Track message replied event. "Communication: Replied to the message" event will appear in lead card
document.getElementById(“cq-popup-js-input”).onblur = function() {
    dashly.trackMessageInteraction('{{ sending_id }}', 'replied');
};
 
//Track whether lead followed a link in the message
document.getElementById(“cq-link”).onclick = function() {
    dashly.trackMessageInteraction('{{ sending_id }}', clicked);
};
 
//Pop-up close function
document.getElementById('cq-popup-btclose').onclick = function () {
 document.getElementById('cq-popup-bg').remove();
 document.getElementById('cq-popup').remove();
}

Click "Create and launch" if all settings are correct and if you want it to start working right now. Alternatively, click "Create and launch later".

Important: check all settings very carefully. You can't delete auto messages, only turn them off.

Read more about how to collect JS-messages statisics in this article.

Powered by