eNd*_*ddy 7 google-analytics angularjs cordova ionic-framework ionic
我正在尝试将Angulartics与Ionic Framework结合使用.但是,谷歌分析没有任何跟踪.这是如何设置它.
index.html.slim文件
<script src="lib/angulartics/src/angulartics.js">
<script src="lib/angulartics/src/angulartics-ga-cordova.js">
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
(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', '#{ENV['GOOGLE_ANALYTICS_ID']', { 'cookieDomain': 'none' });`
Run Code Online (Sandbox Code Playgroud)将它添加到我的角度模块中
angular.module('app', ['angularMoment', 'angulartics', 'angulartics.google.analytics.cordova', 'ngCordova'])`
Run Code Online (Sandbox Code Playgroud)在路由中添加$ analyticsProvider到我的配置
.config ($analyticsProvider, $stateProvider, $urlRouterProvider) ->
Run Code Online (Sandbox Code Playgroud)我没有在谷歌分析仪表板上获得任何数据.有人可以解释如何在我的离子项目中安装Angulartics.
请在此处查看 angulartics-ga-cordova 脚本文件: https: //github.com/luisfarzati/angulartics/blob/master/src/angulartics-ga-cordova.js
在第 48 行,它期待 GAPlugin。
var analytics = window.plugins && window.plugins.gaPlugin;
Run Code Online (Sandbox Code Playgroud)
您需要将此脚本添加到主索引文件中。https://github.com/phonegap-build/GAPlugin
然后你可以像这样添加你的谷歌跟踪信息。
myApp.config ($analyticsProvider, googleAnalyticsCordovaProvider) ->
$analyticsProvider.firstPageview(true)
googleAnalyticsCordovaProvider.trackingId = GOOGLE_ANALYTICS_ID
Run Code Online (Sandbox Code Playgroud)
另外,如果您使用phonegap 构建,则需要将以下行添加到您的config.xml 文件中。
<gap:plugin name="com.adobe.plugins.gaplugin" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1411 次 |
| 最近记录: |