2013-07-23 50 views
0

所以我安裝了phonegap插件來運行谷歌分析。我使用插件來設置它,沒有問題。不過,我無法建立與Google Analytics的連接。Phonegap GaPlugin拒絕連接

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 

我不知道下一步該怎麼做,我已經看到了需要修改ErrorHandling中呼籲不要找HTTPS請求的參考,但我想希望它只是一個錯誤在我的代碼或一個配置錯誤。任何人都有見識?

回答

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。