I am developing a front-end only JavaScript web application (used technologies are HTML5, CSS and JavaScript). This application is injected into a mobile application, that takes my JS web app and displays it in a fancy way.
I would like to track user's activities in my app using Google Analytics, but the problem is that my JS application injected into the mobile app doesn't have a regular URL that is needed when using GA for websites / web apps, but it's also not a mobile application to try GA for mobile apps.. The result is a hybrid between mobile and web application and I can only edit my JS application.
I have made the following image to visualize my problem better.
Using jsconsole.com I can programatically access my app and also check its console even when it is uploaded in iPresent. There are no errors. If I alert the app's URL, I got file URI:
alert( $( location ).attr( 'href ') );
//returns file:///var/mobile/..../index.html
I have tried many solutions-wanna-be (i.e. this or this), none of them works. But I am a beginner at this field, just blindly attempting to solve this, so probably missed some important note. Cookies works fine in my apps in iPresent.
My last GA code I used:
<script>
(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','//www.google-analytics.com/analytics.js','ga');
if(window.localStorage) {
ga('create', 'UA-NUMBER-1', 'none', {
'storage': 'none'
, 'clientId': window.localStorage.getItem('ga_clientId')
});
ga(function(tracker) {
window.localStorage.setItem('ga_clientId', tracker.get('clientId'));
});
}
else {
ga('create', 'UA-NUMBER-1', 'none');
}
ga('send', 'pageview');
</script>
Is it possible to make GA work with this hybrid web application that doesn't have a regular URL, but file URI? If so, how?
Thank u!