Trigger engagement by Javascript code

Engage allows users to show offers at the right time to match their behavior on the site.

Among them, there is a method to freely control the timing by Javascript code.

How to Setup

1. Select “Triggered by Javascript code” from the engagement setting.

2. Save your engagement at once and go back to the engagement report.

3. Click “Action” -> “View code” from the current engagement, you will get the engage ID and  Javascript code.

The engage ID consists of a random number. It is embedded in the Javascript code and used to trigger the relative engagement.

4. Insert the Javascript code to your website, and make sure the code will be triggered on the showing page.

Notice that the code must be fired on the showing page as you set for the engagement.

Install examples

The Javascript code is as follows.

window.Ptengine && window.Ptengine('showEngagement', 1573210609511422)

Example 1: Adding the code to an HTML code.

<button id="loginBtn" onclick="window.Ptengine && window.Ptengine('showEngagement', 1573210609511422)">login</button>

Example 2:Adding the code to a native Javascript.

document.getElementById("loginBtn").addEventListener("click", function(){ window.Ptengine && window.Ptengine("showEngagement", 1573210609511422); });

Notice that the number “1573210609511422” meant Engage ID. Be sure to change the engage ID if you want to trigger your own engagement.

Hits: 350