技术控

    今日:124| 主题:49179
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Introducing GA Spy For Google Analytics

[复制链接]
离心DIEOUT 发表于 2016-10-13 02:09:06
163 5

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

Introducing GA Spy For Google Analytics-1 (publishing,sufficient,instrument,resources,requested)
This is a guest post byStephen Harris fromSeer Interactive. He was kind enough to share his awesome solution in this blog, so I’m very grateful indeed for his contribution.
   If Google Tag Manager is loaded as the primary instrument for tracking on a webpage (as it should be), then all webpage tracking could and should be configurable via GTM. But we don’t always control the circumstances, and it’s not uncommon to face hardcoded Google Analytics tracking outside of GTM.
  Perhaps GA tracking cannot be removed from the website source code quickly enough. Maybe the website is on a publishing schedule that doesn’t suit measurement needs, or maybe the folks responsible for the website don’t have sufficient resources. Whatever the reason, you got a “no” when you
    requested  insisted on removal. (You  did  insist on removal, didn’t you?)
  Or what about when there are hardcoded GA commands in a platform or plugin? It could be screwing with your data. But chances are it’s not doing anything at all (because it’s tracking to the nonexistent default GA tracker) and there seems to be no way to get it to work through GTM.
   And even when all tracking runs through Google Tag Manager, some things can be difficult (or impossible) to implement using the tag templates (such as addingGA plugins, or defining Universal Analytics tracker field defaults).
  Here’s a solution.
   1.2. A Good Spy Starts With Research
   2. Reliability And Caveats
   2.1. Uncommon Behavior For A Common Library
   2.2. Cannot Intercept Hardcoded Pageviews From GA
   3.3. Listening From GTM
   4.2. Access Hardcoded GA Command Data Via GTM
  1. Spying On GA

   You can grab the code on GitHub . Copy-paste it either into a Custom HTML Tag in Google Tag Manager, or load it in the page template proper.
   It’s called GA Spy because it can silently hijack and control all tracking that relies on Google’s Universal Analytics library ( analytics.js ). Effectively, this is a Google Analytics listener that does karate.

Introducing GA Spy For Google Analytics-2 (publishing,sufficient,instrument,resources,requested)

   To put this in layman’s terms, the script listens for interactions with the ga() interface, returning the arguments passed to the function for you to process for whatever purpose you want. For example, you can automatically copy all calls to ga('send'...) to dataLayer.push() syntax, allowing you to fluently replicate hardcoded Universal Analytics tracking in Google Tag Manager.
   This blog post is written assuming the hardcoded tracking is for Universal Analytics, but there is a version of the script for the async GA library (ga.js), to which the same core concepts apply.
  
       
  • Source code for ga-spy.js   
  • Source code for ga-spy_async.js   
  • README  
  1.1. Spy Code 101

   Let’s walk through the script logic. Before implementing, it’s important to get a basic idea of what this script actually does. Once you understand the basics, you’ll also understand why this should be considered a temporary solution . Indeed, you should document the use of this solution, so that when the hardcoded Universal Analytics code is eventually removed from the site, you won’t be left hanging dry with methods that don’t really do anything.
   This section also explains this script’s biggest caveat: GA Spy is not guaranteed to intercept (or even detect) tracking that fires while the page is loading (e.g. the standard GA snippet) if the hack is deployed via GTM. Capturing these requests requires that you deploy the script on the page template itself, which unfortunately might detract from the usefulness for those without developer resources handy.
   For a more technical breakdown, check out the README .
     1.2. A Good Spy Starts With Research
   Let’s start with an overview of how the Universal Analytics tracker works on the page.
    Many GA users are familiar with the JavaScript namespace ga . It’s the global object for tracking with the Universal Analytics library (analytics.js). When the browser loads the page, this object is actually processed twice. First, it’s created by the Universal Analytics snippet , and it queues all commands to ga() while waiting for the library to load. Then, once the library has loaded, the namespace is converted to a full interface which processes each command as it is executed.
123下一页
友荐云推荐




上一篇:Meet the team: Martina Janevska – Problem solver who loves a challenge
下一篇:TLS nonce-nse
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

iizdw 发表于 2016-10-13 06:51:10
顾客不是上帝,顾客只是上当。
回复 支持 反对

使用道具 举报

23733683 发表于 2016-11-1 23:58:42
说不通啊,楼下的你说咋办?
回复 支持 反对

使用道具 举报

近日我浮躁 发表于 2016-11-13 05:03:12
啥玩应呀
回复 支持 反对

使用道具 举报

蹲厕所丶找爱 发表于 2016-11-15 19:26:40
看起来好像不错的样子
回复 支持 反对

使用道具 举报

黄丹 发表于 2016-11-21 12:54:13
传说中的沙发???卡卡
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表