本文介绍了用离子框架集成Angulartics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Angulartics与离子框架。但是,没有对谷歌Analytics跟踪。下面是一组不起来。

I am trying to use Angulartics with Ionic Framework. However, nothing is tracking on google analytics. Here is how a set it up.


  1. index.html.slim文件

  1. index.html.slim file

<script src="lib/angulartics/src/angulartics.js">
<script src="lib/angulartics/src/angulartics-ga-cordova.js">

JavaScript的:

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' });` 


  • 把它添加到我的角度模块

  • Added it to my angular module

    angular.module('app', ['angularMoment', 'angulartics', 'angulartics.google.analytics.cordova', 'ngCordova'])`
    


  • 阿迪$ analyticsProvider到我的配置在路线

  • Adde $analyticsProvider to my config in routes

    .config ($analyticsProvider, $stateProvider, $urlRouterProvider) ->
    


  • 我没有得到我的谷歌分析仪表盘的任何数据。可有人请解释如何在我的项目离子安装Angulartics。

    I am not getting any data on my google analytics Dashboard. Can someone please explain how to install Angulartics in my ionic project.

    推荐答案

    请看看在angulartics-GA-科尔多瓦脚本文件在这里:的

    Please take a look at the angulartics-ga-cordova script file here: https://github.com/luisfarzati/angulartics/blob/master/src/angulartics-ga-cordova.js

    在第48行,这是期待GAPlugin

    On line 48, it is expecting the GAPlugin.

    var analytics = window.plugins && window.plugins.gaPlugin;
    

    您需要将这个脚本添加到您的主索引文件。

    You will need to add this script to your main index file. https://github.com/phonegap-build/GAPlugin

    然后,你可以添加你这样的谷歌跟踪信息。

    Then you can add your google tracking info like this.

    myApp.config ($analyticsProvider, googleAnalyticsCordovaProvider) ->
        $analyticsProvider.firstPageview(true)
        googleAnalyticsCordovaProvider.trackingId = GOOGLE_ANALYTICS_ID
    

    此外,如果你正在使用的PhoneGap构建,则需要将下面的行添加到您的config.xml文件。

    Also, if you are using phonegap build, you will need to add the following line to your config.xml file.

    <gap:plugin name="com.adobe.plugins.gaplugin" />
    

    这篇关于用离子框架集成Angulartics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-23 09:51