SlideShare a Scribd company logo
Integrating Google Analytics
      in Android apps
         +Franklin van Velthuizen
              @FranklinNL
       f.vanvelthuizen@colours.nl
Who am I?
Agenda

• Basic integration
 • Pageviews, events, ...
• Take it a step further
• Legal stuff
Why use GA?

• Free
• Highly used among a variety of disciplines
• Additional APIs
• Powerful platform
• Downside: lack of SDK documentation ...
Agenda

• Basic integration
 • Pageviews, events, ...
• Take it a step further
• Legal stuff
Let’s start!
• Download the SDK at
  http://code.google.com/mobile/analytics
• Add the JAR to your build path
• Add the required permissions to your
  manifest
• Sign up at http://www.google.com/analytics
• Create an account and profile
The tracker object
private GoogleAnalyticsTracker tracker;
...
tracker = GoogleAnalyticsTracker.getInstance();
tracker.startNewSession(“UA-...”, context);
...
tracker.stopSession();

Google says: “In onCreate and onDestroy”
but that has implications.
What can we track?

     Activity viewed by a user        Pageview



Interaction with interface elements    Event
Tracking pageviews


(See example project GA Demo v1.)
Tracking pageviews
Dispatching

• Manual dispatch vs automatic dispatch
  tracker.startNewSession(“UA-..., context);
  tracker.startNewSession(“UA-...”, 10, context);


• Batches of max 30 hits in manual mode
• Try to bundle your dispatches
Tracking events


(See example project GA Demo v2.)
Tracking events
Tracking custom vars
 Three-level visitor interaction model
Tracking custom vars
 Three-level visitor interaction model

                               Visitor
Tracking custom vars
 Three-level visitor interaction model

                               Visitor

                               Session
Tracking custom vars
 Three-level visitor interaction model

                               Visitor

                               Session
Tracking custom vars
 Three-level visitor interaction model

                               Visitor

                               Session


                               Page
Tracking custom vars
Tracking custom vars


(See example project GA Demo v3.)
A/B testing
private static final boolean isA =
UUID.randomUUID().getLeastSignificantBits() % 2 == 0;

...

if(isA) {
  setContentView(R.layout.A);
  tracker.trackPageView(“/HomeActivity/A”);
} else {
  setContentView(R.layout.B);
  tracker.trackPageView(“/HomeActivity/B”);
}
Ecommerce tracking

• Add a transaction
• Add items to the transaction
• Send the transaction to the dispatcher
Ecommerce tracking


(See example project GA Demo v4.)
Ecommerce tracking
Campaign tracking

• Android Market campaigns
 • Campaigns using QR codes on bill boards
• General campaign tracking
 • Links in online advertisements
Agenda

• Basic integration
 • Pageviews, events, ...
• Take it a step further
• Legal stuff
Take it a step further

• onCreate and onDestroy yield long visits
• Same for onStart and onStop
• onResume and onPause yield multiple visits
Analytics wrapper class

• Use my Analytics wrapper class (and
  improve it)
• Sessions are stopped in a delayed way using
  a delayed Runnable
Agenda

• Basic integration
 • Pageviews, events, ...
• Take it a step further
• Legal stuff
Legal stuff

• Always inform your users
• If feasible, provide an opt-out possibility
• Use setAnonymizeIp
Resources

• Mobile Developer Documentation (sparse!)
  http://code.google.com/mobile/analytics

• Google Analytics Developer docs
  http://code.google.com/apis/analytics/docs/

• Example code
   http://www.yoki.org/droidconNL/droidconNL.zip

More Related Content

PDF
Google analytics
PPTX
Google Analytics Ppt Final
PDF
Google Analytics intro - Best practices for WCM
PDF
DevFest Kuala Lumpur - Implementing Google Analytics - 2011-09-29.ppt
PDF
GTUG Philippines - Implementing Google Analytics - 2011-10-11
PDF
AnDevCon - Tracking User Behavior Creatively
PDF
implemetning google analytics - 2011-09-24 Google Devfest Chiangmai
PDF
DevFest Chiang Mai - Implementing Google Analytics - 2011-09-24.ppt
Google analytics
Google Analytics Ppt Final
Google Analytics intro - Best practices for WCM
DevFest Kuala Lumpur - Implementing Google Analytics - 2011-09-29.ppt
GTUG Philippines - Implementing Google Analytics - 2011-10-11
AnDevCon - Tracking User Behavior Creatively
implemetning google analytics - 2011-09-24 Google Devfest Chiangmai
DevFest Chiang Mai - Implementing Google Analytics - 2011-09-24.ppt

Similar to Integrating Google Analytics in Android apps (20)

PDF
5 Ways to Make Use of Your Google Analytics
PDF
Google Analytics for Developers
PPTX
Windows Store app using XAML and C#: Enterprise Product Development
PPTX
QA Fest 2018. Slavik Pashanin. Analytics Data Driven Testing
PPTX
Knowing is Understanding: A road trip through Google analytics for Windows Ph...
PDF
Google Analytics for Developers
PPTX
ADF and JavaScript - AMIS SIG, July 2017
PDF
Cómo usar google analytics
PPTX
Designerfair 2011
PDF
Droidcon Paris 2015
PDF
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
PDF
How to use pertinently Google Analytics, by Gilles Barbier
PDF
Track Report & Optimize Your Web Creations
PDF
Bermon Painter - Rapid Prototyping with Vue.js - Codemotion Rome 2019
PDF
Do we need a bigger dev data culture
PDF
Droid con2013 tracking user behavior_tennyson_manheim
PDF
Google Cloud Platform 2014Q1 - Starter Guide
PPTX
SharePoint Saturday Atlanta 2015
PPTX
Advanced Google Analytics
PDF
20200815 inversions
5 Ways to Make Use of Your Google Analytics
Google Analytics for Developers
Windows Store app using XAML and C#: Enterprise Product Development
QA Fest 2018. Slavik Pashanin. Analytics Data Driven Testing
Knowing is Understanding: A road trip through Google analytics for Windows Ph...
Google Analytics for Developers
ADF and JavaScript - AMIS SIG, July 2017
Cómo usar google analytics
Designerfair 2011
Droidcon Paris 2015
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
How to use pertinently Google Analytics, by Gilles Barbier
Track Report & Optimize Your Web Creations
Bermon Painter - Rapid Prototyping with Vue.js - Codemotion Rome 2019
Do we need a bigger dev data culture
Droid con2013 tracking user behavior_tennyson_manheim
Google Cloud Platform 2014Q1 - Starter Guide
SharePoint Saturday Atlanta 2015
Advanced Google Analytics
20200815 inversions
Ad

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Spectroscopy.pptx food analysis technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation theory and applications.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
cuic standard and advanced reporting.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Cloud computing and distributed systems.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Electronic commerce courselecture one. Pdf
Chapter 3 Spatial Domain Image Processing.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
Spectroscopy.pptx food analysis technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation theory and applications.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Unlocking AI with Model Context Protocol (MCP)
cuic standard and advanced reporting.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Cloud computing and distributed systems.
Ad

Integrating Google Analytics in Android apps

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: \n
  • #5: Management API, Data Export API\n
  • #6: \n
  • #7: \n
  • #8: UA = website profile ID\n
  • #9: \n
  • #10: \n
  • #11: \n
  • #12: \n
  • #13: \n
  • #14: \n
  • #15: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #16: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #17: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #18: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #19: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #20: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #21: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #22: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #23: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #24: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #25: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #26: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #27: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #28: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #29: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #30: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #31: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #32: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #33: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #34: Page = Pageviews and Events\nAlways set your custom var before generating a pageview or event\nExamples: Paid user; Logged in user/Network type; Sections in news app\n
  • #35: \n
  • #36: \n
  • #37: Downside: you need to push an update to start A/B testing\n
  • #38: Transactions and items generate individual hits\n
  • #39: \n
  • #40: \n
  • #41: \n
  • #42: \n
  • #43: - strange visits when switching between activities\n
  • #44: Class composition\n
  • #45: \n
  • #46: Opt-out downside: existing data will not be removed\nsetAnonymizeIp removes the last octet of IP addresses\nEULA is supposed to protect you, instead of gaining permission\n\n
  • #47: \n