Direct Campaign Tracking

Redirectless campaign tracking setup guide
C
Written by ClickFlare
Updated 9 months ago

Depending on the traffic source (ad network) you might be working with, you may need to send visitors directly to your campaign's landing page, instead of using a 302 redirect before they get to the landing page.

This article will guide you through the steps of setting up direct tracking.

Setup requirements:

  • A landing page
  • Access to your landing page's code (to place the required scripts)
  • An offer page

Setting Up Direct Campaign Tracking

Before you begin, you need to make sure you have access to your landing page's source code or edit rights in the platform where your landing page is being created or hosted.

Step 1 - Add your landing page to ClickFlare

To add your landing page to ClickFlare, simply select Landers, on the column on the left of your view inside ClickFlare, then proceed by clicking the [+ New] button to add your landing page's details.

Click here for a detailed guide on how to create landing pages.

Step 2 - Add the Direct Tracking Script to your landing page

Direct tracking script:

<script>!function(){“use strict”;var n=“lp_ref”,t=“cpid”,e=“lpurl”,r=“https://yourtracking.domain”,c=“(?<domain>http(?:s?)://[^/]*)“.concat(“/cf/click”),a=“(?:(?:/(?<cta>[1-9][0-9]*)/?)|(?:/))?“,i=“^”.concat(c).concat(a).concat(“(?:$|(\\?.*))“),o=‘javascript:window.clickflare.l=“(?<original_link>‘.concat(c).concat(a,‘(“|(\\?[^“]*“))).*‘),s=function(){return new RegExp(i,“”)},l=function(){return new RegExp(o,“”)};function u(n){var t=function(n){return n.replace(s(),(function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var c=t[t.length-1].domain;return n.replace(c,r)}))}(n);return’javascript:window.clickflare.l=“‘.concat(t,‘“; void 0;‘)}function f(n,t){if(t&&n&&t.apply(document,[n]),/loaded|interactive|complete/.test(document.readyState))for(var e=0,r=document.links.length;e<r;e++)if(s().test(document.links[e].href)){var c=document.links[e];window.clickflare.links_replaced.has(c)||(c.href=u(c.href),window.clickflare.links_replaced.add(c))}}!function(c,a){var i=document.onreadystatechange;window.clickflare||(window.clickflare={listeners:{},customParams:{},links_replaced:new Set,addEventListener:function(n,t){var e=this.listeners[n]||[];e.includes(t)||e.push(t),this.listeners[n]=e},dispatchEvent:function(n,t){(this.listeners[n]||[]).forEach((function(n){return n(t)}))},push:function(n,t){(this.listeners[n]||[]).forEach((function(n){return n(t)}))}},document.onreadystatechange=function(n){return f(n,i)},f(null,i),setTimeout((function(){!function(c,a){var i,o=function(c,a){var i=new URL(“”.concat(r).concat(c));a.startsWith(“{{“)||i.searchParams.set(t,a);return i.searchParams.append(n,document.referrer),i.searchParams.append(e,location.href),i.searchParams.append(“lpt”,document.title),i.searchParams.append(“t”,(new Date).getTime().toString()),i.toString()}(c,a),s=document.createElement(“script”),u=document.scripts[0];s.async=1,s.src=o,s.onerror=function(){!function(){for(var n=function(n,t){var e=document.links[n];l().test(e.href)&&setTimeout((function(){e&&e.setAttribute(“href”,function(n){var t=n.match(l());if(t){var e=(t.groups||{}).original_link;return e?e.slice(0,-1):n}return n}(e.href))}))},t=0,e=document.links.length;t<e;t++)n(t)}()},null===(i=u.parentNode)||void 0===i||i.insertBefore(s,u)}(c,a)})))}(“”.concat(“/cf/tags”,“/”).concat(new URL(window.location.href).searchParams.get(“cftmid”)||“{{__CONTAINER_ID__}}“),new URL(window.location.href).searchParams.get(t)||“{{__CAMPAIGN_ID__}}“)}();</script>

Copy the full direct tracking script above (including <script> tags, then paste it in the <body> section of your landing page.

Make sure to replace the REPLACE_WITH_YOUR_TRACKING_DOMAIN_NAME with your actual tracking domain name.

When successfully added, your landing page code should look similar to the one below:

<!doctype html>
<html lang="en">
<head>

<script>!function(){“use strict”;var n=“lp_ref”,t=“cpid”,e=“lpurl”,r=“https://yourtracking.domain”,c=“(?<domain>http(?:s?)://[^/]*)“.concat(“/cf/click”),a=“(?:(?:/(?<cta>[1-9][0-9]*)/?)|(?:/))?“,i=“^”.concat(c).concat(a).concat(“(?:$|(\\?.*))“),o=‘javascript:window.clickflare.l=“(?<original_link>‘.concat(c).concat(a,‘(“|(\\?[^“]*“))).*‘),s=function(){return new RegExp(i,“”)},l=function(){return new RegExp(o,“”)};function u(n){var t=function(n){return n.replace(s(),(function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var c=t[t.length-1].domain;return n.replace(c,r)}))}(n);return’javascript:window.clickflare.l=“‘.concat(t,‘“; void 0;‘)}function f(n,t){if(t&&n&&t.apply(document,[n]),/loaded|interactive|complete/.test(document.readyState))for(var e=0,r=document.links.length;e<r;e++)if(s().test(document.links[e].href)){var c=document.links[e];window.clickflare.links_replaced.has(c)||(c.href=u(c.href),window.clickflare.links_replaced.add(c))}}!function(c,a){var i=document.onreadystatechange;window.clickflare||(window.clickflare={listeners:{},customParams:{},links_replaced:new Set,addEventListener:function(n,t){var e=this.listeners[n]||[];e.includes(t)||e.push(t),this.listeners[n]=e},dispatchEvent:function(n,t){(this.listeners[n]||[]).forEach((function(n){return n(t)}))},push:function(n,t){(this.listeners[n]||[]).forEach((function(n){return n(t)}))}},document.onreadystatechange=function(n){return f(n,i)},f(null,i),setTimeout((function(){!function(c,a){var i,o=function(c,a){var i=new URL(“”.concat(r).concat(c));a.startsWith(“{{“)||i.searchParams.set(t,a);return i.searchParams.append(n,document.referrer),i.searchParams.append(e,location.href),i.searchParams.append(“lpt”,document.title),i.searchParams.append(“t”,(new Date).getTime().toString()),i.toString()}(c,a),s=document.createElement(“script”),u=document.scripts[0];s.async=1,s.src=o,s.onerror=function(){!function(){for(var n=function(n,t){var e=document.links[n];l().test(e.href)&&setTimeout((function(){e&&e.setAttribute(“href”,function(n){var t=n.match(l());if(t){var e=(t.groups||{}).original_link;return e?e.slice(0,-1):n}return n}(e.href))}))},t=0,e=document.links.length;t<e;t++)n(t)}()},null===(i=u.parentNode)||void 0===i||i.insertBefore(s,u)}(c,a)})))}(“”.concat(“/cf/tags”,“/”).concat(new URL(window.location.href).searchParams.get(“cftmid”)||“{{__CONTAINER_ID__}}“),new URL(window.location.href).searchParams.get(t)||“{{__CAMPAIGN_ID__}}“)}();</script>


</head>

<body>
.
.
<a href="https://your-tracking-domain.com/cf/click/1">Your Call to Action</a>
.
</body>
</html>
Important note: Besides placing the direct tracking code in the <body> section of your landing page, you will need to make sure that you are replacing your call-to-action URLs with the click tracking URLs of your ClickFlare account. Failing to replace the call-to-action URLs with those of ClickFlare, will make it impossible for ClickFlare to track your landing page's click-through rate. Click here for more details.

Step 3 - Creating your Campaign

Once you have committed all required changes to your landing page, it is time to create your campaign in ClickFlare.

Go to Campaigns, then click the [+ New] button to start creating your campaign.

After specifying your campaign's traffic source, cost tracking model and name, it is very important to switch the transition between ad and campaign to Direct.

This setting will tell ClickFlare to use the direct tracking script present in your landing page, instead of waiting for users to be redirected through a redirect tracking campaign link.

Step 4 - Specify your campaign destination settings

Continue to your campaign's destination settings, where you'll be able to specify the landing page (to which you previously added the direct tracking script to) and the offers your visitors will be routed to when they click on your landing page's call-to-action buttons.

Please note that when using direct tracking to track the performance of your campaigns, your funnel will be limited to one landing page only.

Click here for more information about campaign destination settings.

Step 5: Getting your campaign tracking link

Finally, after specifying your campaign's destination settings, you will need to get the tracking URL of your newly created campaign.

The correct campaign link for your direct tracked campaign will be the one under Lander Tracking URL

As you may notice, in the screenshot above, we have highlighted the cpid=xxxxxxxxxxx which corresponds to the unique ID of your campaign.

Direct tracking works based on the campaign ID value passed to your landing page URL query string through the cpid parameter.

Did this answer your question?