Skip to content
/ Ti.GA Public
forked from benbahrenburg/Ti.GA

Google Analytics Native SDK modules for Titanium

License

Notifications You must be signed in to change notification settings

slash-84/Ti.GA

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ti.GA

A Google Analytics module that provides just what you need, in a consistent way.

This module was developed as a result of the frustration in chasing Google's changing API between SDK versions. Since most developers only care about a few features of the SDK that is what this module provides.

Downloads

Download the compiled modules at:

Source

Looking for the source? Check out the following:

How to...

Android specifications

If you use ti.playservices, you need to remove the /lib folder in the Android zip module.

Also you need to edit the android manifest, in tiapp.xml, as specified in the Google Analytics dev guide:

<android xmlns:android="http://schemas.android.com/apk/res/android">
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>
      <!-- Get permission for reliable local dispatching on non-Google Play devices. -->
      <uses-permission android:name="android.permission.WAKE_LOCK"/>

      <!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background dispatching on non-Google Play devices -->
      <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver" android:enabled="true">
        <intent-filter>
          <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
        </intent-filter>
      </receiver>
      <service android:name="com.google.android.gms.analytics.AnalyticsService" android:enabled="true" android:exported="false"/>

      <!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable installation campaign reporting -->
      <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" android:exported="true">
        <intent-filter>
          <action android:name="com.android.vending.INSTALL_REFERRER"/>
        </intent-filter>
      </receiver>
      <service android:name="com.google.android.gms.analytics.CampaignTrackingService"/>
    </application>
  </manifest>
</android>

Add to your project

You add the Ti.GA module into your project using the require keyword as shown below.
var ga = require('ti.ga');

Module Level Options

Enable Trace You can enable or disable trace by calling ga.setDebug. Provide true to enable or false to disable this option.

The following shows how to enable this feature

ga.setDebug(true);

OptOut Google Analytics provides the ability to opt out of collecting information. By default you are opt'ed into collecting information.

The following is an example on how to optout of collecting information:

ga.setOptOut(false);

If you have at one point opt'ed out you need to explicitly opt back in. Below is an example of opt'ing into collecting information:

ga.setOptOut(true);

setDispatchInterval The dispatch interval is how often in seconds that Google Analytics information should be submitted to Google.

The following show how to set the dispatch interval to 15 seconds.

ga.setDispatchInterval(15);

setTrackUncaughtExceptions On iOS you can set use the setTrackUncaughtExceptions to track unhandled exceptions.

The following is an example on how to enable this feature.

ga.setTrackUncaughtExceptions();

Dispatch The dispatch method submits data to Google Analytics. Google Analytics will automatically do this for your, but you can "force" this programmatically. If you are going to use this it should only be done while your application is not active and has a network connection.

ga.dispatch();

Creating a tracker

~~~ var tracker = ga.createTracker({ trackingId:'YOUR GOOGLE ANALYTICS TRACKER ID', useSecure:true, debug:true }); ~~~

Adding User ID

If you want to associate user IDs with your analytics data, you'll first need to create a view with User ID enabled.

Then, when a user logs in, pass a unique identifier for that user with the setUserID method on the tracker. You only need to set this once, and all hits for the session from then on will be attributed to that ID.

tracker.setUserID('my-user-id');

Adding Screen Viewed

More coming... here is an example for now

tracker.addScreenView('my-cool-view2');

Adding Timing

More coming... here is an example for now

    tracker.addTiming({
        category:"myCategory-Timing",
        label:"myLabel",
        name:"myName",
        time:1
    });

Adding Event

More coming... here is an example for now

    tracker.addEvent({
        category:"myCategory-Event",
        action:"myAction",
        label:"myLabel",
        value:1
    });  

Adding Social Network

More coming... here is an example for now

    tracker.addSocialNetwork({
        network:"facebook",
        action:"myAcount",
        target:"myTarget"
    });  

Adding Exception

More coming... here is an example for now

    tracker.addException({
        description:"my error description",
        fatal:false
    });  

Contributors

Thank you to all of the contributors.

A special thank you to Mauro Piccotti for helping to address Google Play conflicts

Licensing & Support

This project is licensed under the OSI approved Apache Public License (version 2). For details please see the license associated with each project.

Developed by Ben Bahrenburg available on twitter @bencoding

About

Google Analytics Native SDK modules for Titanium

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 72.0%
  • Java 20.3%
  • Python 5.3%
  • JavaScript 2.4%