1

I created an HTML file that uses Google Analytics. When I use it at a URL on my web host, it is working perfectly. Can I instead use it locally on my Android device, instead of hosted on my website?

Purpose: I have an Android device with one single page HTML. Once the HTML opens in a browser, button on the page would fire Google Analytics events. It would increment the count in Google Analytics for a particular goal.

How can I set that up?

3 Answers 3

1

Google Analytics tracking code should work on a local HTML file, as long as you have internet service.

Open your local file with GA tracking, then login to your Analytics service. View Real Time Reporting and see if there is a user on the site. If there is, that should be you and the test succeeded.

0

You can't do that. If you don't have hosting how can google analytics (or anything) check to see if the file exists and therefore validate?

2
  • It sounds like there is a static HTML file stored on a single device. I think they are asking if a GA tracking code will work in a static HTML file on Android. I'd think it might, as long as the device has internet service. Not that I know how to put a static HTML file into a place where a browser can open it on Android either. Apr 8, 2018 at 10:51
  • 1
    @StephenOstermiller You can download the html file on your Android device and open it in your downloads folder and it will run in your default browser. I once created an html application and did it this way. I found it incredibly hard to actually save the file to a permanent folder though, and so I kept having to open it from the downloads folder.
    – Michael d
    Apr 8, 2018 at 13:11
0

You have indicated that you are using Tag Manager (in your tags), and there are actually several caveats that you need to consider when running from the file system or from localhost. It is possible, just needs some tweaks.

Simo describes the steps quite well here: https://www.simoahava.com/analytics/run-google-tag-manager-google-analytics-local-files/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.