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.

For Developers: Adding Dynamic Web Content to Tracking Codes

Article: 000050280
Updated: July 25, 2024

Dynamic web content enables you to change the page that is served on your site based on a visitor's characteristics. This article will provide an example of what adding dynamic web content to Lead Gen & CRM's tracking code returns.


Article Contents

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

Light Bulb IconTip: Are you looking for information about Constant Contact’s Email and Digital Marketing product? This article is for Constant Contact’s Lead Gen & CRM product. Head on over to the Email and Digital Marketing articles by clicking here. Not sure what the difference is? Read this article.

 

Example Dynamic Web Content

Adding dynamic web content requires that you create new tracking code, or edit the existing tracking code. The following is an example of tracking code that will show an alert containing the visitor's first name:
 

<!-- Your Lead Gen & CRM Tracking Code -->
    
<!-- Start Dynamic Script Example -->
    <script type="text/javascript">
    var callThisOnReturn = function(resp) {
        if (resp && resp.contact) {
            alert('Hi there ' + resp.contact['First Name']);
        }
    };
    _ss.push(['_setResponseCallback', callThisOnReturn]); 
    </script>
<!-- End Dynamic Script Example -->
 

Note: Constant Contact offers Professional Services to assist with custom coding.

To create dynamic content for a lead, make sure that you include the callThisOnReturn 
function within your script. This function receives a response object with a lead object inside that will contain all of the standard and custom fields attributed to the lead. All manipulation of the page needs to occur within this function, as the response lead object will not be available outside.

Custom fields will be referred to by their label in the system, just like the system fields. Also, Lead Gen & CRM will only return fields that contain values. This applies to system fields and custom fields. If there is no value in the field, the field will not be returned in the response object at all. As such, all code referencing specific fields should be written with the understanding that the fields sometimes will not be present if empty. This is opposed to returning a null or a blank value—they are omitted from the response.

The response object returned will have two attributes. The first attribute is trackingID, which is always present, even if the lead is unknown. This attribute can be used when passing data to Lead Gen & CRM to establish tracking. The other attribute is the contact object. This object will contain all the known fields about the lead.

In the above example code, resp.trackingID would return the trackingIDresp.contact would return the full contact object, and resp.contact['First Name'] would return the First Name attribute of the contact object.

 


Did this article answer your question?


Constant Contact Logo

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