2013-06-24 2 views
0

(https://marketplace.appcelerator.com/apps/5081?2014113336)에서 Google 웹 로그 분석 모듈을 다운로드했습니다.Google 애널리틱스 모듈을 티타늄 및 Android 앱에 사용하는 방법은 무엇인가요?

나는이 모듈을 (iam이 처음으로 모듈을 사용하는 것처럼) 내 앱 이벤트 및 다운로드를 추적하는 데 사용하는 방법을 모릅니다. 아무도 도와주세요. 여기 내 코드는

//Application Window Component Constructor 
function ApplicationWindow() { 
var win = Ti.UI.createWindow({ 
     backgroundImage:'ui/handheld/android/images/Background_320x480.png', 
     tabBarHidden:true 
}); 
win.orientationModes = [Ti.UI.PORTRAIT]; 

var screenWidth = Ti.Platform.displayCaps.platformWidth; 
var screenHeight = Ti.Platform.displayCaps.platformHeight; 

function GetHeight(value) { 
     var temp = (value * 100)/320; 
     return parseInt((screenHeight * temp)/100); 
} 

function GetWidth(value) { 
     var temp = (value * 100)/240; 
     return parseInt((screenWidth * temp)/100); 
} 

var parent = Ti.UI.createView({}); 

//Set up analytics 
      var GA = require("analytics.google"); 
      GA.debug = true; 
      //GA.trackUncaughtExceptions = true; 

      var tracker = GA.getTracker("UA-41976730-1"); 

var image1 = Ti.UI.createImageView({ 
     image:"images/settings.png", 
     top:'10', 
     right:'8' 
}); 
parent.add(image1); 

image1.addEventListener('click', function() { 
     var win4 = Ti.UI.createWindow({ 
     title: 'Settings', 
     url: "settings.js", 
     tabBarHidden:true 
     }); 
    win4.open({modal:true}); 
}); 

var image2 = Ti.UI.createImageView({ 
     image:'images/.png', 
     layout:'horizontal', 
//  left: GetWidth(35), 
     top:40 
}); 
parent.add(image2); 

var image3 = Ti.UI.createImageView({ 
     image:'images/NewsButton.png', 
     top : GetHeight(85), 
     left : GetWidth(35) 
}); 
parent.add(image3); 

image3.addEventListener('click', function() { 
     var win2 = Ti.UI.createWindow({ 
     title: 'Industry News', 
     tabBarHidden:true, 
     backgroundColor:"white" 
     }); 
     win2.orientationModes = [Ti.UI.PORTRAIT,Ti.UI.LANDSCAPE_LEFT,Ti.UI.LANDSCAPE_RIGHT]; 
      var webview = Titanium.UI.createWebView({ 
        url:'' 
     }); 
     win2.add(webview); 

     win2.open({modal:true}); 
}); 

var label1 = Ti.UI.createLabel({ 
     text:'Industry News', 
     color:'#0768A9', 
     width:'auto', 
     height:'auto', 
     font:{fontFamily:'Trebuchet MS',fontWeight:'bold'}, 
     top : GetHeight(150), 
     left : GetWidth(32) 
}); 
parent.add(label1); 

var image4 = Ti.UI.createImageView({ 
     image:'images/BlogButton.png', 
     top : GetHeight(85), 
     right : GetWidth(35) 
}); 
parent.add(image4); 

image4.addEventListener('click', function() { 
     var win3 = Ti.UI.createWindow({ 
       title: 'Software Alerts', 
       tabBarHidden:true, 
       backgroundColor:"white" 
     }); 
     win3.orientationModes = [Ti.UI.PORTRAIT,Ti.UI.LANDSCAPE_LEFT,Ti.UI.LANDSCAPE_RIGHT]; 
     var webview = Titanium.UI.createWebView({ 
       url:'' 
     }); 


     win3.add(webview); 
     win3.open({modal:true}); 
}); 

var label2 = Ti.UI.createLabel({ 
     text:'Software Alerts', 
     color:'#0768A9', 
     width:'auto', 
     height:'auto', 
     font:{fontFamily:'Trebuchet MS',fontWeight:'bold'}, 
     top : GetHeight(150), 
     right : GetWidth(29) 
}); 
parent.add(label2); 

var image5 = Ti.UI.createImageView({ 
     image:'images/TVButton.png', 
     top : GetHeight(185), 
     left : GetWidth(35) 
}); 
parent.add(image5); 

image5.addEventListener('click', function() { 
     var win4 = Ti.UI.createWindow({ 
       backgroundColor:'#fff', 
       title: ' TV', 
       url: "Pages/tv.js", 
       tabBarHidden:true 
     }); 



     win4.open({modal:true}); 
}); 

var label3 = Ti.UI.createLabel({ 
     text:'TV', 
     color:'#0768A9', 
     width:'auto', 
     height:'auto', 
     font:{fontFamily:'Trebuchet MS',fontWeight:'bold'}, 
     top : GetHeight(250), 
     left : GetWidth(50) 
}); 
parent.add(label3); 

var image6 = Ti.UI.createImageView({ 
     image:'images/LibraryButton.png', 
     top : GetHeight(185), 
     right : GetWidth(35) 
}); 
parent.add(image6); 

image6.addEventListener('click', function() { 
     var win5 = Ti.UI.createWindow({ 
       title: 'Knowledge Library', 
       tabBarHidden:true 
     }); 
     win5.orientationModes = [Ti.UI.PORTRAIT,Ti.UI.LANDSCAPE_LEFT,Ti.UI.LANDSCAPE_RIGHT] 
     var webview = Titanium.UI.createWebView({ 
       url:'' 
     }); 


     win5.add(webview); 
     win5.open({modal:true}); 
}); 

var label4 = Ti.UI.createLabel({ 
     text:'Knowledge Library', 
     color:'#0768A9', 
     width:'auto', 
     height:'auto', 
     font:{fontFamily:'Trebuchet MS',fontWeight:'bold'}, 
     top : GetHeight(250), 
     right : GetWidth(20) 
}); 
parent.add(label4); 

win.add(parent); 

return win; 

if(Titanium.Network.networkType == Titanium.Network.NETWORK_NONE){ 
var alertDialog = Titanium.UI.createAlertDialog({ 
      title: 'WARNING!', 
      message: 'Check your network connection and try again.', 
      buttonNames: ['OK'] 
     }); 
     alertDialog.show(); 
} 
} 

module.exports = ApplicationWindow; 
+0

무엇이 문제입니까? – likeitlikeit

답변

1

모듈 작성자는 몇 가지 지침을 제시합니다. 일부 trackEvents 누락처럼 https://github.com/MattTuttle/titanium-google-analytics/blob/master/mobile/ios/documentation/index.md

가 보이는 : 그는 또한 예를 가지고

var GA = require('analytics.google'); 
var tracker = GA.getTracker("UA-XXXXXXX-X"); 
tracker.trackEvent({ 
    category: "my event category", 
    action: "clicked", 
    label: "how many (c)licks?", 
    value: 3 
}); 

을 app.js 파일 : https://github.com/MattTuttle/titanium-google-analytics/blob/master/mobile/ios/example/app.js

당신이 추적 이벤트를 기록 후, 당신이 필요로 나타납니다 거래를 생성 한 다음 거래를 추적하여 Google에 제출하십시오.

... 
var transaction = GA.makeTransaction({ 
    id: "hi", 
    tax: 0.6, 
    shipping: 0, 
    revenue: 24.99 * 0.7 
}); 
transaction.addItem({ 
    sku: "ABC123", 
    name: "My Alphabet", 
    category: "product category", 
    price: 24.99, 
    quantity: 1 
}); 
tracker.trackTransaction(transaction); 
+0

거래 부분은 GA의 다른 부분과 관련이 있다고 생각합니다. 나는. trackEvent() 이외에는 다른 것이 필요하지 않습니다. – Federico

관련 문제