Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2469] iOS: Google Analytics not working in 3.1 or later but work in 3.0

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2013-06-25T22:34:14.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsregression
ReporterFrancisco Alejandro Cruz Castro
AssigneeShak Hossain
Created2013-06-21T21:34:10.000+0000
Updated2016-03-08T07:41:31.000+0000

Description

Steps to Reproduce

send an 'UA-XXXXX' param to function GAnalytics and use the result into html property of webview (iOS)

Actual Result

nothing

Expected Result

hit in google analytics

Attachments

FileDateSize
.log2013-06-21T21:34:21.000+00003144245
diagnostic5241221320631449696.log2013-06-21T21:34:29.000+00005685
google_analytics.js2013-06-21T21:34:30.000+0000677
Ti.Google.Analytics.js2013-12-12T03:51:08.000+000010349

Comments

  1. Carter Lathrop 2013-06-25

    Hello Francisco, Is it possible for you to provide a full test case? One that is easily copied and pasted into an app.js that will run and display the problem at hand. This will ensure understanding on both sides and allows us to come to a resolution faster. Also be sure to provide a set of "steps to reproduce" that will ensure we are following the same process you are to see the problem in question. Thanks, Carter
  2. Mostafizur Rahman 2013-12-12

    We tried to reproduce this issue with a sample test case. It’s working as expected with Titanium SDK 3.1.3 GA. Please try the sample code and let us know if the problem persists.

    Testing Environment:

    Ti CLI 3.3.0 Titanium SDK: 3.1.3.GA iOS simulator 7.0

    Test Code

    app.js
        // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#fff');
       
       var gaModule = require('Ti.Google.Analytics');
       var analytics = new gaModule('UA-XXXXXXXXXX');
       
       // Call the next function if you want to reset the analytics to a new first time visit.
       // This is useful for development only and should not go into a production app.
       //analytics.reset();
       
       // The analytics object functions must be called on app.js otherwise it will loose it's context
       Ti.App.addEventListener('analytics_trackPageview', function(e) {
       	analytics.trackPageview('/iPad' + e.pageUrl);
       });
       
       Ti.App.addEventListener('analytics_trackEvent', function(e) {
       	analytics.trackEvent(e.category, e.action, e.label, e.value);
       });
       
       // Starts a new session as long as analytics.enabled = true
       // Function takes an integer which is the dispatch interval in seconds
       analytics.start(10, true);
       
       // create tab group
       var tabGroup = Ti.UI.createTabGroup();
       
       //
       // create base UI tab and root window
       //
       var win1 = Ti.UI.createWindow({
       	title : 'Tab 1',
       	backgroundColor : '#fff'
       });
       
       // track page view on focus
       win1.addEventListener('focus', function(e) {
       	analytics.trackPageview('/win1');
       });
       
       var tab1 = Titanium.UI.createTab({
       	icon : 'KS_nav_views.png',
       	title : 'Tab 1',
       	window : win1
       });
       
       var label1 = Titanium.UI.createLabel({
       	color : '#999',
       	text : 'I am Window 1',
       	font : {
       		fontSize : 20,
       		fontFamily : 'Helvetica Neue'
       	},
       	textAlign : 'center',
       	width : 'auto'
       });
       
       win1.add(label1);
       
       //
       // create controls tab and root window
       //
       var win2 = Titanium.UI.createWindow({
       	title : 'Tab 2',
       	backgroundColor : '#fff'
       });
       
       // track page view on focus
       win2.addEventListener('focus', function(e) {
       	analytics.trackPageview('/win2');
       });
       
       var tab2 = Titanium.UI.createTab({
       	icon : 'KS_nav_ui.png',
       	title : 'Tab 2',
       	window : win2
       });
       
       var label2 = Titanium.UI.createLabel({
       	color : '#999',
       	text : 'I am Window 2',
       	font : {
       		fontSize : 20,
       		fontFamily : 'Helvetica Neue'
       	},
       	textAlign : 'center',
       	width : 'auto'
       });
       
       win2.add(label2);
       
       //
       //  add tabs
       //
       tabGroup.addTab(tab1);
       tabGroup.addTab(tab2);
       
       // open tab group
       tabGroup.open();
       
       // You don't need to call stop on application close, but this is just to show you can call stop at any time (Basically sets enabled = false)
       Titanium.App.addEventListener('close', function(e) {
       	analytics.stop();
       });
       
       
       

    Steps to Test

    1. Create a new project 2. Update app.js file and analytics ID 4. And run iOS simulator 7.0 5. Click on tab 2 6. Open google analytics real time view

    Expected Result

    Check your google analytics real time view

JSON Source