Lead Gen & CRM
How can we help you?
Search our help articles, video tutorials, and quickstart guides

You've got this. You've got us. Search our Knowledge Base to quickly find answers to your questions.

Retrieving Lead Gen & CRM Tracking IDs

Article: 000050403
Updated: July 18, 2024

Learn how to retrieve the tracking ID needed to establish a tracked device for a lead

When adding leads using the API, or when posting to a native form endpoint directly without using native form capture code, you must provide the tracking ID in order to establish a tracked device for the lead. This article will cover several different methods of retrieving this ID.


Article Contents

 
 
Users:
Administrators 
Company Managers  
Marketing Managers  
Sales Managers  
Salespersons  
Jr. Salespersons  


Retrieving via Dynamic Page Content

One method of retrieval requires that you modify your page tracking code.

To get the ID using dynamic page content feature, add the following code beneath your page tracking code:

<script type="text/javascript">
    var callThisOnReturn = function(resp) {
        if (resp) {
            var SharpSpringTracking = resp.trackingID;
        }
    };
    _ss.push(['_setResponseCallback', callThisOnReturn]); 
   </script>

Once added, the variable SharpSpringTracking will contain the tracking ID. You can then use that in your own code to place the tracking ID where needed.


Note: Constant Contact offers Professional Services to assist with custom coding and API issues


 
Retrieving via .PHP

The following code will fetch the cookie value in .PHP:

if (isset($_COOKIE['__ss_tk'])) {
		$SharpSpringTracking = $_COOKIE['__ss_tk'];
}

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



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 Lead Gen & CRM cookie as follows:

SharpSpringTracking = getCookie('__ss_tk');

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



After Retrieval 

Once you have the cookie assigned to a variable, you can then write code to pass it on to Lead Gen & CRM. That may involve writing it to a hidden field on the form, or adding it to information being passed to an API call. This will be up to your developer to determine once the cookie has been fetched.

The Lead Gen & CRM cookie should have a value with the following format:

201611|581a09d2ba899bcc078b477a
 



Important Information Regarding Retrieval

Be aware that the format of the cookie returned by the code cannot be used in the API as-is.

Again, retrieved cookie code is returned in the following format: 

201611|581a09d2ba899bcc078b477a


However, the API can only utilize the cookie code in either of the following formats:

  • 201611_581a09d2ba899bcc078b477a
  • 201611%581a09d2ba899bcc078b477a (encoded)
 


Did this article answer your question?


Constant Contact Logo

Copyright © 2025 · All Rights Reserved · Constant Contact · Privacy Center