如何通过代码将支付方式排除为Google Analytics中的推介? [英] How to exclude payment method as referral in Google Analytics, through code?

查看:197
本文介绍了如何通过代码将支付方式排除为Google Analytics中的推介?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的付款网关在Google Analytics中显示为推介。我已阅读了一些内容,看起来有两个选项可以解决此问题:


  1. 将条目添加到引荐排除在Google Analytics管理页面中列出。 (适用于Google Universal Analytics)

  2. utm_nooverride = 1 附加到支付网关返回页面的URL中。显然,这不是Google Universal Analytics的解决方案。

本文很好地解释了这个问题。



我想知道是否有其他替代方案,因为我管理的是需要此修复程序的600多个Google Analytics帐户,并且手动更新每个帐户的推介排除列表需要很长时间。我需要一个类似于选项#2的选项,在那里我可以有一个URL参数或我可以在analytics.js跟踪pageview之前发送某种设置,告诉它忽略推荐。

解决方案

不知道这是否有任何副作用,但以下内容似乎有效:Universal Analytics具有设置 - 方法,允许您覆盖字段在它们被发送到服务器之前。因此,您可以覆盖引荐来源字段,并将其设置为已经属于您的引荐排除列表的某个域。

因此,如果您想保留utm_nooverride参数,您可以执行某些操作如:

 (function(i,s,o,g,r,a,m){i ['GoogleAnalyticsObject'] = r; i [r] = i [r] || function(){
(i [r] .q = i [r] .q || [])。push(arguments)},i [ r] .l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m。 parentNode.insertBefore(a,m)
})(window,document,'script','// www.google-analytics.com/analytics.js','ga');

ga('create','UA-XXXXXX-XX','auto');
if(location.search.indexOf('nooverride')> -1){
ga('set','referrer','yourdomain.com');
}
ga('send','pageview');

如果查询字符串包含nooverride(当然,您可以为参数选择其他名称)引荐者被设置为您的域名,并且您的域名(或者至少应该是)已经是您的引荐排除列表的一部分。



您可能想要测试这更广泛,但它为我工作时,我掀起了这个问题的测试页,所以它应该是值得探讨的。


My payment gateways show up as referrals in Google Analytics. I've read a bit about it, and it looks like there are two options to fix this:

  1. Adding an entry to the Referral Exclusion List in Google Analytics admin page. (works with Google Universal Analytics)
  2. Attach utm_nooverride=1 to the URL of the payment gateway return page. Apparently this is not a solution for Google Universal Analytics.

This article does a good job of explaining the issue.

I would like to know if there is another alternative, because I am managing 600+ Analytics accounts that need this fix, and manually updating the Referral Exclusion List for each account will take a lot of time. I need an alternative similar to option #2, where I can have a URL parameter or where I can send some kind of settings to analytics.js just before it tracks the pageview, telling it to ignore the referral.

解决方案

No idea if this has any side effects, but the following seems to work: Universal Analytics has a "set"-method that allows you to override fields before they are send to the server. So you can override the referrer field and set it to some domain that's already part of your referral exclusion list.

So if you want to keep the utm_nooverride parameter you could do something like:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXX-XX', 'auto');
if(location.search.indexOf('nooverride') > -1) {
    ga('set', 'referrer', 'yourdomain.com');
}
ga('send', 'pageview');

If the query string contains "nooverride" (of course you can choose any other name for the parameter) the referrer is set to the name of your domain, and your domain is (or at least should be) already part of your referral exclusion list.

You might want to test this more extensively, but it worked for me when I whipped up a test page for this question so it should be worth exploring.

这篇关于如何通过代码将支付方式排除为Google Analytics中的推介?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆