0

所以我安装了 phonegap 插件来运行谷歌分析。我用plugman设置的,没问题。但是我无法建立与谷歌分析的连接。

document.addEventListener("deviceready", function(){
        console.log('device ready');
        config.gaPlugin = window.plugins.gaPlugin;
        config.gaPlugin.init(console.log('ga plugin inititalized'), console.log('ga plugin failed'), config.analyticsCode, 1);
    }, false);

而不是得到一个连接,我得到一个回应

W/GAV2(12581): Thread[WebViewCoreThread,5,main]: Need to call initialize() and be in fallback mode to start dispatch.

我认为init函数是初始化?但是,当我每 5 秒设置一次时,连接被拒绝。

W/GAV2(12581): Thread[GAThread,5,main]: Connection to https://ssl.google-analytics.com refused
W/GAV2(12581): Thread[GAThread,5,main]: Exception sending hit: HttpHostConnectException

我不知道接下来要做什么,我已经看到需要修改错误处理调用以不查找 https 请求的参考,但我希望它只是我的代码中的错误或配置错误。有人有见识吗?

4

1 回答 1

0

我使用以下与 GAPlugin 一起使用的代码

gaInit: function() {
    gaPlugin.init(gaSuccessConnect, gaFail, "UA-XXXXXX-3", 10);
},

gaSuccess: function() {
    console.log('Successfully connected to Google Analytics');
},

gaSuccessConnect: function() {
    console.log('Successfully initiated connection to Google Analytics');
    gaTrackPage();
},

gaFail: function() {
    console.warn("Failed to connect to Google Analytics");
},

gaTrackPage: function() {
    gaPlugin.trackPage(gaSuccess, gaFail, "index.html");
    console.log('Tracking index');
},

gaTrackPageView: function(page) {
    var index = "index.html";
    var trackpage = index.concat(page);
    console.log('Tracking ' + page);
    gaPlugin.trackPage(gaSuccess, gaFail, trackpage);
},

并从 onDeviceReady 调用 gaInit。

于 2013-12-23T19:37:05.993 回答