Contentsquare

Sample Implementation Project

Custom variables

The ContentSquare platform uses custom variables to collect data from the site. These assist with page mapping and are used in Segmentation rules. The platform supports up to 20 personalized variables.

Below are the custom variables that will be configured for your site. Please double check that you're happy with the data ContentSquare will collect and inform us if any of the data points are deprecated.

  • {{Insert custom variables here}}

Dynamic variables - Traffic Sources

The tag has also been configured to allow for the capture of stardardised traffic sources. By default this will include:

  • utm_source
  • utm_medium
  • utm_campaign
  • gclid

Please contact your Implementation Manager if you would like to adjust these to capture other traffic sources. Traffic Sources can be added later through 'Mapping', however this method allows for the automatic segmentation and bypasses this manual step for the most commonly used traffic.

Our technical documentation on Custom vars

Main tag to install

TMS Installation — The script below can be added as a new "Custom HTML tag" through most TMS platforms like Google Tag Manager (a step-by-step guide). It must be fired on every page ("All pages" firing rules) including iframes and subdomains.

Manual (HTML) Installation — The script below is needed on every page of the domain (including iframes and subdomains) just before the closing </body> tag .

<script type="text/javascript">
//v2.3 - DC20190604
(function () {
  window._uxa = window._uxa || [];

  var trafficMediumPattern;
  var trafficCampaignPattern;
  var trafficSourcePattern;
  var campaignGclid;

    if(document.location.search!=''){
      //Please change the URL strings below to choose your traffic parameters
      var mediumParName = 'utm_medium';
      var campaignParName = 'utm_campaign';
      var sourceParName = 'utm_source';
      var regPattern = '=([a-zA-Z0-9\-\_]+)';
      //Variable regPattern is limited to the regex defined above, anything else will be missed
      trafficMediumPattern = new RegExp(mediumParName+regPattern);
      trafficMediumPattern = trafficMediumPattern.exec(document.location.search);

      trafficCampaignPattern = new RegExp(campaignParName+regPattern);
      trafficCampaignPattern = trafficCampaignPattern.exec(document.location.search);

      trafficSourcePattern = new RegExp(sourceParName+regPattern);
      trafficSourcePattern = trafficSourcePattern.exec(document.location.search);

      campaignGclid = new RegExp('gclid=([a-zA-Z0-9\-\_]+)');
      campaignGclid = campaignGclid.exec(document.location.search);
    }
  try {
    //Please edit key strings below to work with parameters defined above (if desired)
      if (trafficMediumPattern !== null && typeof trafficMediumPattern !== 'undefined') {
        if (typeof trafficMediumPattern[1] !== 'undefined'){
          window._uxa.push(["trackDynamicVariable", {key: 'Medium', value: trafficMediumPattern[1].toLowerCase()} ]);
        }
        }
      if (trafficCampaignPattern !== null && typeof trafficCampaignPattern !== 'undefined') {
        if (typeof trafficCampaignPattern[1] !== 'undefined'){
          window._uxa.push(["trackDynamicVariable", {key: 'Campaign', value: trafficCampaignPattern[1].toLowerCase()} ]);
        }
      }
      if (trafficSourcePattern !== null && typeof trafficSourcePattern !== 'undefined') {
        if (typeof trafficSourcePattern[1] !== 'undefined'){
          window._uxa.push(["trackDynamicVariable", {key: 'Source', value: trafficSourcePattern[1].toLowerCase()} ]);
        }
      }
      if (campaignGclid !== null && typeof campaignGclid !== 'undefined') {
        if (typeof campaignGclid[1] !== 'undefined'){
          window._uxa.push(["trackDynamicVariable", {key: 'Gclid', value: 'true'} ]);
        }
      }
      //Add any custom variables here
      }
    catch(e){}
      if (typeof CS_CONF === 'undefined') {
        window._uxa.push(['setPath', window.location.pathname+window.location.hash.replace('#','?__')]);
        var mt = document.createElement("script"); mt.type = "text/javascript"; mt.async = true;
        mt.src = "//t.contentsquare.net/uxa/{{TAG ID}}.js";
        document.getElementsByTagName("head")[0].appendChild(mt);
        } else {
          window._uxa.push(['trackPageview', window.location.pathname+window.location.hash.replace('#','?__')]);
        }
})();
</script>
© Contentsquare, 2020.