简体   繁体   中英

Using Google Analytics on a Javascript widget

I've built Javascript widgets that have been installed on other websites.

How can I use google analytics on my widgets like I would use analytics on a web page to track the traffic?

FYI, the Javascript code for my widgets is created from PHP pages.

Thanks

It would likely be extremely unethical to include tracking snippets in JS widgets that get installed on client sites. Unless they're iframe widgets, but I don't see anything about iframes in your post.

However, technically, there's no technical difference between implementing basic GA tracking on a site versus a JS widget. You just load the GA library, initialize it and send events. Any basic tracking manual would do.

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