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

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

问题描述

我的支付网关在 Google Analytics(分析)中显示为推荐.我已经阅读了一些关于它的内容,看起来有两个选项可以解决这个问题:

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. 在 Google Analytics(分析)管理页面的推荐排除列表中添加一个条目.(适用于 Google Universal Analytics)
  2. utm_nooverride=1 附加到支付网关返回页面的 URL.显然,这不是 Google Universal Analytics 的解决方案.
  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.

我想知道是否有其他替代方法,因为我管理着 600 多个需要此修复程序的 Analytics 帐户,并且手动更新每个帐户的引荐排除列表将花费大量时间.我需要一个类似于选项 #2 的替代方法,在那里我可以有一个 URL 参数,或者我可以在它跟踪浏览量之前向 analytics.js 发送某种设置,告诉它忽略引用.

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.

推荐答案

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

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.

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

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');

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

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天全站免登陆