facebook

The correct way to incorporate google analytic into your app

  1. MobiOne Archive
  2.  > 
  3. Examples, HOW-TOs
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #349778 Reply

    fbod383
    Member

    create a google analytics account, select website, not mobile app and get your UA ID number

    add this function to you custom.js

    function gaReporting(targetScreenId){
    console.log(“GA General Tracking”);

    if(targetScreenId == ”){
    targetScreenId = ‘app-start’;
    }

    (function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,’script’,’/analytics.js’,’ga’);

    ga(‘create’, ‘UA-XXXXXXX-XX‘, {
    ‘storage’:’none’,
    ‘clientId’: ‘YOURAPPNAME
    });

    ga(‘send’, ‘pageview’, {‘page’:targetScreenId})
    }

    Add this to line 43 in your (appname).html

    <script type=”text/javascript” src=”analytics.js”></script>

    http://www.google-analytics.com/analytics.js

    then download the google analytics JS, save as analytics.js file and add it to you www folder

    Search for: if(“http:”!=a&&”https:”!=a)throw”abort”; and comment it out

    when building the app, or testing, DO NOT regenerate the html file

Viewing 1 post (of 1 total)
Reply To: The correct way to incorporate google analytic into your app

You must be logged in to post in the forum log in