如何从code触发谷歌Analytics(分析)? [英] How to trigger Google Analytics from code?

查看:140
本文介绍了如何从code触发谷歌Analytics(分析)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序读取我的网站上(HTML)文件,我想跟踪访问使用谷歌分析该文件。作为GA的Javascript不获取读文件时执行,所以不进行跟踪。有没有办法直接从code触发GA或替代,以不添加一堆依赖从.net应用程序执行JavaScript?

My app reads an (html) file from my website, and I would like to track accesses to that file using Google Analytics. As the GA Javascript does not get executed when reading the file, it is not tracked. Is there a way to trigger GA directly from code or alternatively, to execute the Javascript from a .NET app without adding a bunch of dependencies?

推荐答案

谷歌Analytics(分析)的工作原理是通过javascript制作的WebRequest回谷歌的服务器上。如果你想以编程方式做到这一点,你就必须使这个网络要求自己。我会用小提琴手或萤火捕捉请求看起来什么,当你在浏览器加载页面等。然后你就可以使用同一个URL在.NET应用程序。

Google Analytics works by making a webrequest through javascript back to Google's server. If you want to do this programmatically, you just have to make this web request yourself. I would use Fiddler or FireBug to capture what the request looks like when you load the page in your browser. Then you can use that same URL in your .Net app.

这篇关于如何从code触发谷歌Analytics(分析)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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