Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Google Analytics setup for native packaged web app

  1. #11
    Sencha User Ola GP's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    28
    Answers
    1

    Default

    Quote Originally Posted by MatteoFrancia View Post
    I have to:
    1. put the js file in the app root
    2. set up a require in my app.js
    3. include the file even in the app.json file
    4. ...something more?
    Thanks for your help
    If I remember correctly, this is how I did it:
    1. Create a Google Analytics Account. When prompted what kind of type you will track, choose the type "Web site", not "App". Then you will need to fill out an url. This can be confusing since the app don't have an url. But typing any url here will work. I just used the url for the website for my app.
    2. Download the js-file from the above Github repo. Put the js-file in the app root.
    3. Add the js-file as an asset in app.json
    4. In the launch event in app.js, add this code:
      Code:
      ga_storage._setAccount('UA-XXXXXXXX-X');
      ga_storage._setDomain('none');
      ga_storage._trackPageview('/index.html');
      This will make a track event every time the app is started.
      (Make sure you set the correct Analytics ID on the first line.)
    5. If you need to track custom events, this is possible. For example, if you have an app with some products, and you want to see which products are the most popular, you can set up a track event every time the user opens a certain product view. Just use a code like this when a product view is opened:
      Code:
      ga_storage._trackEvent('Products', 'Show product', 'My awesome product name');
      For more info about custom event tracking, see this page:
      https://developers.google.com/analyt...ntTrackerGuide
    My app used Sencha Touch 2.1.0. I don't know if you need a different approach with other versions. Probably not.

  2. #12
    Sencha User
    Join Date
    Aug 2010
    Posts
    315
    Answers
    4

    Default

    Hi, if you use Sencha Touch + Phomegap there is a plugin (Android and iOS).
    I 've used it in 2 of my app, the tracking is on Google Analitycs Mobile, you can see real time tracking and what kind of mobile device. and also track custom event. It work also offline, the stat are stored in a sqllite db and then sync when the device is online again.
    You track events not pages, is an app not a website.
    https://github.com/phonegap-build/GAPlugin


  3. #13

    Default

    Thanks Ola and thanks steve for your valuable feedback
    Quote Originally Posted by steve1964 View Post
    Hi, if you use Sencha Touch + Phomegap there is a plugin (Android and iOS).
    I 've used it in 2 of my app, the tracking is on Google Analitycs Mobile, you can see real time tracking and what kind of mobile device. and also track custom event. It work also offline, the stat are stored in a sqllite db and then sync when the device is online again.
    You track events not pages, is an app not a website.
    https://github.com/phonegap-build/GAPlugin
    steve I got a little doub about where to put this code:
    Code:
    var gaPlugin; 
    gaPlugin = window.plugins.gaPlugin; 
    gaPlugin.init(successHandler, errorHandler, "UA-12345678-1", 10);
    To make the gaPlugin variable accessible every where in my sencha app?

    Edit: I work w/ Sencha Architect

  4. #14
    Sencha User
    Join Date
    Aug 2010
    Posts
    315
    Answers
    4

    Default

    You need phonegap in order to use the above plugin, you need to package with phonegap. I dont use architect, you have to setup this kind of things in app.js. I use xCode and Eclipse to package my app, so i cant help with architect.
    Un saluto...

  5. #15

    Default

    Quote Originally Posted by steve1964 View Post
    You need phonegap in order to use the above plugin, you need to package with phonegap. I dont use architect, you have to setup this kind of things in app.js. I use xCode and Eclipse to package my app, so i cant help with architect.
    Un saluto...
    Ok this is not a problem, I use Eclipse too but I write the "base" code in Architect.
    The point is that, Eclipse, xCode, Notepad or whatever, you have to write the
    Code:
    var gaPlugin; 
    gaPlugin = window.plugins.gaPlugin; 
    gaPlugin.init(successHandler, errorHandler, "UA-12345678-1", 10);
    code somewhere to initialize the variable gaPlugin which is necessary to track events...

    Where did you put the above code?

    Grazie mille per l'aiuto

  6. #16
    Sencha User
    Join Date
    Aug 2010
    Posts
    315
    Answers
    4

    Default

    In app.js,, launch event

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •