Capturing Event Data with Javascript

First how familiar would you say you are with jQuery? Below are some methods we've baked into our platform to allow you to pass information or call javascript to and from your site and the Justuno Overlay.

First here are some tidbits you'll need to understand about our system.

  • We do make jQuery available on both your own site and our iframe overlay, but we do it in a way that it will not conflict with jQuery you might already have installed on your site. Because of that you must reference jQuery via the "jju" variable, so instead of $(this).xyz you would write jju(this).xyz.
  • We have two different Javascript windows and two different CSS windows that you can edit to further customize your promotions. Each JS/CSS is either labeled with "Popup" or "Tab". The "Popup" windows are to add code inside of our Justuno iFrame while the "Tab" windows are to add code to your own site easily for those promotions. DO NOT use the actual JS or CSS opening/closing <script> and <style> tags as we automatically put then in the code.

Whew! Now that we got that explanation over with we can move on to some actual example code:

Here's how you can call javascript in either your own site or the Justuno Overlay Iframe when someone engages with the promotion:

 

Fire a Javascript Event on your website for any Justuno Interaction

Depending on your needs you can create as many Justuno event handlers to fire for specific events in Justuno like impressions, engagements, and conversions and a bunch of properties will be passed to the handler function to do so with as you please.

This code can either be put on a specific promo via the custom code / Tab JS window or you can place it on your website so that it's loaded on necessary or all pages (the recommended way).

// use either impression, engagment or conversion in the second property depending on the event you want to fire this function for.

/*

values passed to this function include:

email = email address that was just submitted

the first two are fired during a promotion impressions or what would be an impression but is blocked because user is in an a/b test control group:
eventname = Targeted Overlay
eventname = Tab Click
eventname = Control Variation

the rest here are fired when a visitor engages with a promotion:
eventname = Engagement - Facebook
eventname = Engagement - Google Plus
eventname = Engagement - Twitter Tweet
eventname = Engagement - Email Signup
eventname = Engagement - LinkedIn Share
eventname = Engagement - Twitter Follow
eventname = Engagement - Pinterest Follow
eventname = Engagement - Instagram Follow
eventname = Engagement - Videos Watched
eventname = Engagement - Incentivized Form
eventname = Engagement - VK Follow
eventname = Engagement - Reddit Subscribe
eventname = Engagement - Google Follow
eventname = Engagement - LinkedIn Follow
eventname = Engagement - Intro Continue Click
eventname = Engagement - Unlocked or CTA Click
eventname
= Engagement - Unlocked or CTA View
eventname = Engagement - Plugin
eventname = Engagement - Push Notification Subscribe
eventname = Engagement - Facebook Messenger opt-in
eventname = Engagement - Item Added To Cart
eventname = Engagement - Product Click-Through
eventname = Engagement - SMS Text Message
promotitle =    Title of the promo

cmid = Promo ID

options = {
"promo_options":{
"bluecore_lists":[bluecore_lists],
"bluecore_listId":[bluecore_listId],
"bluecore_source":[bluecore_source],
},
"promo_coupon":"[string]"
}

the form value will be an array containing all field names and their values that were submitted in the form, it will automatically append the IP and the country code.
form = [{"name":"email","value":"[string]"},{"name":"IP","value":"174.26.194.175"},{"name":"CountryCode","value":"US"}]

*/

window.juapp=window.juapp||function(){(window.juapp.q=window.juapp.q||[]).push(arguments)}

juapp('trackFunc','[impression|engagement|conversion]',function(email, eventname, promotitle, cmid, options, form){

// do something, for example you could add to a GTM dataLayer

dataLayer.push({
'event': 'popupEmail',
'popupEmail': email
});

});

Fire a Javascript Callback within the Justuno Iframe after an engagement

Basically whenever an engagement happens (email submission, form submission, social follow/like/share...) the function named ju_callback() will be fired in the Justuno Overlay Iframe if it exists in them. So if you add it to the Pop up JS window it will be called within the Justuno Iframe.

function ju_callback(t,email,coupon){

// do something

/* The following is just some explanation of the information passed to this function.
for instance if this is in the Overlay JS and you wanted to do something with ju_qs("customvar") which is equal to your customvar querystring when someone engages with the promotion overlay. Here's where you would do it.

There are 3 variables passed into this function. The first variable "t" will equal the integer value of the engagement type. Below is a list of the integer values to strings for reference:

1 = Facebook
2 = Google Plus
3 = Twitter TWeet
5 = LinkedIn Share
6 = Twitter Follow
7 = Pinterest Follow
8 = Instagram Follow
9 = Youtube Subscribe
10 = Incentivized Form (any form integration submission)
11 = VK Follow
12 = Reddit Subscribe
13 = Google Follow
14 = LinkedIn Follow
15 = Intro Continue Click
16 = Unlocked Click
17 = Engagement - Unlocked View
18 = Engagement - Plugin
19 = Engagement - Push Notification Subscribe
20 = Engagement - Facebook Messenger Opt In
21 = Engagement - Item Added to Cart
22 Engagement - Product Click Through
23 Engagement - SMS Click
The second variable "email" will equal the email address entered if it's a newsletter signup promotion.

Finally, the "coupon" variable will equal the coupon code given to your user. This will only be populated if you are using the coupon layer. This comes in handy if you need to automatically apply the coupon code to your user's session when the coupon code is a unique coupon code.
*/
}

 

Want to supercharge your onsite promotions? Check out Justuno Plus, a premium plan for marketers featuring exclusive access to our AI product feed, a dedicated CRO Strategist, and more. Justuno Plus