jquery - Passing UTM Parameters to Intercom -


i trying pass utm parameters intercom track users chat , coming from.

intercom recommends capturing information , setting jquery cookies plugin. here documentation.

i using latest release of cookies , updated code intercom provides bit.

<script type="text/javascript" src=".../js/js.cookie.js"></script>  <script type="text/javascript"> function geturlparam(name) {   return decodeuricomponent((new regexp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(window.location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null; }  jquery(document).ready(function($) {   if(geturlparam('utm_source') !== null) {     cookies.set('utm_source', geturlparam('utm_source'), {       expires: 365,       path: '/',       domain: window.location.hostname,       secure: true     });   }    if(geturlparam('utm_campaign') !== null) {     cookies.set('utm_campaign', geturlparam('utm_campaign'), {       expires: 365,       path: '/',       domain: window.location.hostname,       secure: true     });   }    if(geturlparam('utm_medium') !== null) {     cookies.set('utm_medium', geturlparam('utm_medium'), {       expires: 365,       path: '/',       domain: window.location.hostname,       secure: true     });   } }); </script> 

i know working correctly because using javascript console in chrome developer tools, can call

cookies.get('utm_source') 

and actual value if url contains particular utm parameter.

but reason, not passing intercom , code (located in footer) passing information looks like:

<script>   window.intercomsettings = {    app_id: "zto7cy6x",    "utm_source": cookies.get('utm_source'),    "utm_medium": cookies.get('utm_medium'),    "utm_campaign": cookies.get('utm_campaign')   }; </script> 

what doing wrong?

do have intercom script following settings? having window.intercomsettings variable difined not enough. must have intercom script sends out settings intercom.

<script>     window.intercomsettings = {        app_id: "zto7cy6x",        "utm_source": cookies.get('utm_source'),        "utm_medium": cookies.get('utm_medium'),        "utm_campaign": cookies.get('utm_campaign')     }; </script> <script>(function(){var w=window;var ic=w.intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomsettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.intercom=i;function l(){var s=d.createelement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/wprz7ktj';var x=d.getelementsbytagname('script')[0];x.parentnode.insertbefore(s,x);}if(w.attachevent){w.attachevent('onload',l);}else{w.addeventlistener('load',l,false);}}})()</script> 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -