所以我安装了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请求的参考,但我希望它只是我的代码中的错误或配置错误。有人有洞察力吗?
答案 0 :(得分: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。