Phonegap和Google Analytics(分析)不工作 [英] Phonegap and Google Analytics are not working

查看:173
本文介绍了Phonegap和Google Analytics(分析)不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用phonegap建立应用程式,想要使用Google Analytics(分析)。我使用CLI安装了插件,并将以下代码行实现到我的 deviceReady 事件:

I'm building an app with phonegap and wanted to use Google Analytics. I installed this plugin with the CLI and implemented the following lines of code into my deviceReady event:

analytics.startTrackerWithId('UA-*******-5');
analytics.trackView('Frontsite');

(确定我用真实的跟踪代码替换了****)。

(For sure I swapped the **** with my real tracking code).

问题是我没有得到错误,所以我认为插件工作(或不是),但应用程序不是跟踪。当我转到Google Analytics(分析)页面(我创建了移动跟踪属性)时,它不会在实时标签中显示我的手机(或模拟器)。

Problem is I don't get an error, so I think the plugin works (or not), but the App is not tracked at all. When I go to the Google Analytics page where I created the mobile tracking property, it doesn't show my phone (or simulator) in the realtime-tab.

推荐答案

不需要使用插件。您可以使用测量协议跟踪ID直接调用google analytics API。它在Andriod,IOS,Windows和Blackberry中正常工作。

No need to use plugin. You can directly call the google analytics API by using measurement protocol tracking id. It works fine in Andriod, IOS, Windows and Blackberry.

var dataform = {};
            dataform.v = 1;
            dataform.tid = "UA-xxxxxxxx-2";
            dataform.cid = "device id";
            dataform.t = "appview";
            dataform.an = "name";
            dataform.av = "0.0.1";
            dataform.cd = "Home Screen";
var url = "http://www.google-analytics.com/collect";
            $.ajax(url, {
                type: "post",
                contentType: "text/plain",
                data: dataform
            })
                    .done(function(result) {
                            alert("success");

                    })
                    .fail(function(error) {
                            alert("fail");

                    });

这篇关于Phonegap和Google Analytics(分析)不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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