Forum Documentation Showcase Pricing Learn more

Need some help to add javascript in the page

Hi all,

Im using sharpspring for Marketing Automation. In the header i added the code for tracking, this is working fine. But i want to get the tracking ID from sharpspring in the page.

This is possible, i had a manual from Sharpspring but my knowledge about javascripting is a little bit low :wink:

Can someone help me?

Retrieving via JavaScript

The following JavaScript function will allow you to fetch a cookie’s value:

function getCookie(cname) {

  • var name = cname + “=”;*
  • var decodedCookie = decodeURIComponent(document.cookie);*
  • var ca = decodedCookie.split(’;’);*
  • for(var i = 0; i <ca.length; i++) {*
  •    var c = ca[i];*
    
  •    while (c.charAt(0) == ' ') {*
    
  •    	c = c.substring(1);*
    
  •    }*
    
  •    if (c.indexOf(name) == 0) {*
    
  •        return c.substring(name.length, c.length);*
    
  •    }*
    
  • }*
  • return “”;*
    }

Once put into place, you can call the function for the SharpSpring cookie as follows:

SharpSpringTracking = getCookie(’__ss_tk’);

Once added, the variable SharpSpringTracking will contain the cookie value.

Thanks a lot!