简体   繁体   中英

Event Tracking with Google Analytics in a Standalone HTML App

I work with internet connected touchscreens that can run HTML projects. The HTML projects must be self contained in that all assets like scripts, css, images, videos, etc... must be in the local file structure on the hardware in case the unit loses internet connectivity. The units have a built-in web server for this basic use with a chromium browser.

I'm wanting to track events on specified DOM elements using Google Analytics so those events can be recorded when the unit has an active internet connection.

For example... If a button is clicked to perform some sort of action on the page and in that action I want to include an audit call to send that event to my GA account. Pretty standard use of this: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

However, I can't seem to figure out how to make this work on a page that isn't hosted on a typical website. Everything I'm finding doesn't deal with this specific scenario and always relies on a page hosted on a typical site.

How can I track events using Google Analytics on a standalone HTML page?

Thanks, ~Mike

Can you try with sending your events by using Google Tag Manager to Google Analytics.It is quite easy to implement.

Try with adding the Google Tag Manager code, you get once you create the account in tag manager.And add your analytics property id to a custom variable in tag manager.Then create a page view type tag with analytics property id.

sample link for your reference https://support.google.com/tagmanager/answer/6102821?hl=en

Once you are able to link tag manager to your HTML page you can start tracking the page view event.Similarly, you can track other types of events.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM