Help: Automation

Looking for training?  Join a webinar or schedule a one-on-one to go over ActiveCampaign & your marketing strategy!

Site Tracking From Email Campaigns

Our site tracking feature will save all page views for every visitor to your site. At some point you’ll need to associate those visits with an ActiveCampaign contact. You’ll notice our tracking code has a variable for the email address:

var trackcmp_email = '';
var trackcmp = document.createElement("script");
trackcmp.async = true;
...

This is set to empty by default, meaning page visits are not being associated to a particular ActiveCampaign contact (but are still being tracked based on a browser cookie). At some point during visits to your site you should associate that visitor with an email address – either through a members-only area, or by asking them for their email address (through a form). Once the email is used as the trackcmp_email variable value, all past and future visits are immediately associated with that contact in ActiveCampaign.

One common scenario is when sending an email campaign – you probably want link clicks to your site (where you have our tracking code installed) to be tracked from that point forward. Keep in mind the original link click is already tracked and associated with the contact through our standard reporting feature. However, standard link tracking only captures visits to that exact page, and won’t track where the visitor goes next. This is where site tracking comes into play.

When you create your campaign you can set up your links to include the subscriber’s email address in the URL:

Then when the subscriber clicks on a link from the campaign, their email is carried over to your site:

mysite.com/index.php?email=test@test.com

Then just extract that email from the URL and use it for the trackcmp_email variable:

function GetUrlValue(VarSearch) {
  var SearchString = window.location.search.substring(1);
  var VariableArray = SearchString.split('&');
  for (var i = 0; i < VariableArray.length; i++) {
    var KeyValuePair = VariableArray[i].split('=');
    if (KeyValuePair[0] == VarSearch) {
      return KeyValuePair[1];
    }
  }
}
var email = GetUrlValue("email");
var trackcmp_email = (typeof(email) != "undefined") ? email : '';
...

If there is an email in the URL, the script uses that. If not, it sets it to empty (which is the default).

Connect