0

Two days ago I added 'paypal.com' to the referral exclusions on the google analytics account for my website.

My website is submitting its data to GA via google tag manager.

So far, yesterday's visits are not excluding paypal as referral.

Do you know if the process of setting the referral exclusions with google tag manager is different than it is for google analytics? do you know how long do the referral exclusions settings take to have any effect?

user229044
  • 232,980
  • 40
  • 330
  • 338
Pedro Rolo
  • 28,273
  • 12
  • 60
  • 94
  • 1
    How are you setting the referral exclusion through GTM? I'm not familiar with how it's done there. There is the Referral Exclusion list which is done through GA Admin interface though, under the "Tracking Info" section. – nyuen Sep 16 '15 at 17:26
  • I am not setting the referral exclusion through GTM. I am doing so through the GA admin interface like you already know how to do. I wonder if this still works when using the gtm script instead of the ga one. – Pedro Rolo Sep 16 '15 at 17:43
  • 1
    It's not different and it should work immediately. Google does not trim the fields on saving, so check in your referral exclusion settings for accidental whitespace. – Eike Pierstorff Sep 17 '15 at 08:12
  • Hi. There is no problem at all with whitespaces – Pedro Rolo Sep 17 '15 at 09:30
  • 1
    Can you give an example of a domain you are trying to exclude, and how you are excluding it? I have seen some inconsistency with using "www.example.com" and "example.com", although have not done extensive testing myself. – nyuen Sep 17 '15 at 20:57
  • i was just using paypal.com – Pedro Rolo Sep 18 '15 at 14:20

1 Answers1

0

I sorted this out by implementing the referral exclusion in javascript, right before the gtm tag:

var previousReferrer = Cookies.get("previous_referrer")
if(document.referrer.match(/paypal\.com/))
  Object.defineProperty(document, 
                        "referrer",
                        {get : function(){ 
                          return previousReferrer; }});
Cookies.set("previous_referrer", document.URL);

please notice that as it is hard to change the document.referrer variable we need to use defineProperty and that this only works in modern browsers (safari <=5, Firefox < 4, Chrome < 5 and Internet Explorer < 9 ):

How to manually set REFERER header in Javascript?

Community
  • 1
  • 1
Pedro Rolo
  • 28,273
  • 12
  • 60
  • 94
  • 1
    Alternative suggestions here: http://stackoverflow.com/questions/31648105/how-to-exclude-payment-method-as-referral-in-google-analytics-through-code/32624990#32624990, can also be implemented with "set fields" and a lookup variable in GTM. – Eike Pierstorff Sep 18 '15 at 14:36
  • I am not using ga.js but gtm instead. – Pedro Rolo Sep 18 '15 at 14:42
  • 1
    Yes. You can set the referer field that is sent to Analytics in the GTM interface. So you take the predefined "referrer" variable and if it contains "paypal.com" you set the referrer field accordingly. That's only useful if you want to do things without additional javascript purely from within GTM, other than that it's pretty much the same as your solution. – Eike Pierstorff Sep 18 '15 at 14:47