是否有可能使用 UiApp 作为用户界面将有效的 Google Analytics 跟踪器插入到网络应用中?
这将为应用程序所有者提供深入的使用统计信息。
我能想到的唯一可能的替代方案是将对网络应用程序的每次访问(包括用户的 ID)存储在 ScriptDb 中,从数据隐私角度来看是有问题的,并且不提供有关用户的基本信息,例如位置、语言或设备.
最佳答案
是的,这是完全可行的,我有一个内部库。这个概念是你从 google 分析服务器 Urlfetch 一个 gif 并通过查询字符串传递数据。这是工作代码和测试。 Google Analytics 文档引用是内联的:
编辑:我已将以下内容打包为名为 GASAnalytics 的库,并将项目 key “MvzvykyEXRZJoG1Gjj2h1JnHAGDwXQ1CH”添加到此处的“更多 Google Apps 脚本库”列表中:https://docs.google.com/spreadsheet/ccc?key=0AhDqyd_bUCmvdGxjNUpGZkFKcmxsekE3VHNWMEh4amc#gid=0
/**
* hits Google Analytics with a "path" you want to track as a pageview
* e.g. track("UA-ABC123-4", "/track/my/event")
*/
function track(propertyId, path) {
//ref https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting#gifParameters
//https://developers.google.com/analytics/devguides/collection/other/mobileWebsites
var utmGifLocation = "http://www.google-analytics.com/__utm.gif";
// Construct the gif hit url.
var utmUrl = utmGifLocation + "?" +
"utmwv=4.4sa" +
//"&utmcn=1"+ //added - extra - not required
"&utmn=" + (new Date().getTime())+ //unique - cache buster
"&utmhn=" + 'example.com' +
"&utmr=" + '-' +
"&utmp=" + encodeURIComponent(path) +
"&utmac=" + propertyId +
"&utmcc=__utma%3D999.999.999.999.999.1%3B" +
"&utmvid=" + Math.random() +
"&utmip=" + '-';
Logger.log("Fetching " + utmUrl);
var test = UrlFetchApp.fetch(utmUrl);
return;
}
function testTrack() {
// confirm in GA > Realtime (immediate) or Standard Reports > Content > Content drilldown (after 2 hours)
track("UA-heyuseyourown:/!", "/track1/my1/test1");
}
让我们知道你进展如何。
关于google-analytics - 使用 UiService 的 Google Apps 脚本 Web 应用程序可以通过 Google Analytics 进行跟踪吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12475719/