我正在尝试借助此链接将 google analytic 添加到 tizen web-app
https://www.samsungdforum.com/SamsungDForum/ForumView/7e2b7fa90012098b?forumID=abebd8c49fee8b80
但是当我运行我的应用程序时,它抛出错误 -
stats.js 中未定义文件系统
首先,Tizen 在本地文件系统上运行,URL 格式为
file:///
,因此不使用 http
或 https
,Google 跟踪代码管理器不允许这样做。
要解决此问题,请从标记中删除现有的 Google 跟踪代码管理器脚本,并专门针对 Google 跟踪代码管理器使用以下代码片段,但对于 Google Analytics(分析)也可以进行类似的操作。
<body>
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-xxxxxx"
height=0 width=0 style="display: none; visibility: hidden"></iframe>
</noscript>
<script type=text/javascript
src="https://www.googletagmanager.com/gtm.js?id=GTM-xxxxxx"></script>
<script type=text/javascript
src=https://www.google-analytics.com/analytics.js></script>
其次,您需要配置Google Analytics Tag。因为 GA 对网络浏览器设置了一些限制:
-The host making the requests to GA needs to use either `http` or `https` as the protocol.
-The host must support storing the Client ID in browser cookies.
-The host must be able to pass a proper Document Location value (the URL) to Google Analytics.
有关更多信息,请阅读 Google 开发专家撰写的这篇博客文章
https://www.simoahava.com/analytics/run-google-tag-manager-google-analytics-local-files/
当您使用SamsungDForum的示例时,最好在该论坛中转发此示例。 我在那里找到了谷歌分析的另一个例子,它可能对你有帮助。 https://www.samsungdforum.com/SamsungDForum/ForumView/3ad8bd6023af18a7?forumID=1195f8970c4eea64