Help! My referrals are not being tracked!

The Payment Gateway Issue

Valentina Gredler

By Valentina Gredler

Recent posts

Payment Gateway Issue – My referrals are not being tracked

Be the first who receives upcoming Growth Hacking news...

Read More

Google Analytics is great, right? It provides data on every important metric regarding your business and once combined with Tag manager, there is practically nothing you can’t track on your website. Except when it doesn’t do that.

Because sometimes you will come across some annoying issues when tracking your traffic and purchases, which is what happened to us just recently: Our latest fuck up, something we wanted to share with you – So you don’t have to face the same problems we did.

Let’s start off where began: Our customer, a European airline company, was running a campaign and tasked us with tracking all traffic and sales. Easy enough.

We thought.

Normal procedure

We set up Google Analytics and Tag Manager Accounts to track every necessary button, every goal and movement, but something seemed not to be working correctly. A few weeks passed until we discovered that there was a problem:

Because the Airline Company was using an external Payment Provider that ended the session of a user in between – even if it was below 30 minutes – every source we had was the payment provider and not the actual source, meaning that the traffic source of all our goals was “payment.datatrans.biz”. Thanks to that, we couldn’t tell which marketing activity or channel was the most effective up until this point.

But – after some hours of intense brainstorming – we came up with some solutions we would like to share with you: We tried them all, and can finally tell where our purchases are coming from. So what did we do?

 

  1. utm_nooverride=1

Here you can try to add the utm parameter to your marketing links to tell Google Analytics that it should not override your link when passing the payment gateway.

 

  1. Referral Exclusion

In Google Analytics under “Tracking Info” you can add the domains you want to exclude as Referral.

 

We tested those two options on several pages, which did not always work – That’s why we came up with a third option: A Cookie we implemented via Tag Manager. The idea was for the cookie to save the referral source from where the user was coming from – then at the end of the purchase, a script would load the variable “first party cookie” which will then override the payment gateway referral with the original one.

Here’s how it’s done:

Start with your Variable in Your Google Tag Manger. Here you need to set up your 1st Party Cookie Variable, which you can name “ReferrerCookie”.

Referrer Cookie

Next step requires some triggers for the tags that we’ll be setting up in the end.

ReferrerCookie trigger

First, start with the cookie trigger which fires on every referrer that does not contain your URL.

Then we need to set up a trigger for when the payment process was successful. Here you just put in the URL of the “Thank You” page.

Referrer Cookie payment

And now our final step, the Tags to be fired by our trigger. We start with the cookie that saves the referral from where your user was coming from. This Tag needs to be triggered with the cookie trigger apart from the success page. The Tag should then look like this:

Referrer Cookie TGB

 

Here’s the html script for you to copy & paste:

 

<script>

var cookieName = “ReferrerCookie”; // Name of your cookie
var cookieValue = document.referrer; // Value of your cookie
var expirationTime = 172800; // One month in seconds
expirationTime = expirationTime * 1000; // Converts expirationtime to milliseconds
var date = new Date();
var dateTimeNow = date.getTime();

if(document.referrer == “”) {

cookieValue = “(direct) / (none)”;
}
date.setTime(dateTimeNow + expirationTime); // Sets expiration time (Time now + one month)
var expirationTime = date.toUTCString(); // Converts milliseconds to UTC time string
document.cookie = cookieName+”=”+cookieValue+”; expires=”+expirationTime+”; path=/;  domain=.” + location.hostname.replace(/^www\./i, “”); // Sets cookie for all subdomains

</script>

 

And as a second and final Tag, you have the one that is overwriting the referrer from the payment provider. This is how the Tag should look like:

ReferrerCookie Thank you page

 

After you implemented all Variables, Trigger and Tags we suggest waiting 24 hours – Sometimes it just takes a while for all of the data to appear.

Hopefully, this will help you with this particular problem, should you run into it – we know how annoying it can be.

Valentina Gredler

By Valentina Gredler

Recent posts

Payment Gateway Issue – My referrals are not being tracked

Be the first who receives upcoming Growth Hacking news...

Read More

Leave a Comments

Be the first who receives upcoming Growth Hacking news

Top