I have a situation where I generate content (a widget which is composed of simple divs specifically) and serve them to 3rd party sites both synchronously & asynchronously.

While serving those widgets, I want to track the number of presentations and clicks from users using the widgets with Google Analytics.

Is that possible? What is the best approach to face this tracking issue?

2 Answers 2


This is what I'd do, although keep in mind that you probably have to inform the sites where your widget is being displayed about this approach (since it would help avoid confusion for that person running analytics on that site).

In your widget, include your GA tracking code, send a "widget load" event. When the widget is clicked, send the "widget click" event.

An example of such a similar implementation would be olark (live chat widget). Interestingly (and this is something you might want to consider in order to deliver more value to your sites) olark provides GA integration options as well. So not only will the widget send data to your GA, but also it can be implemented to send this data to the site's GA.


You could embed a tracking pixel (or web bug) inside your divs. The pixel is not visible, but gets requested by visitors allowing you to track their visits. You can implement this on your own server, otherwise you can use one of the many tracking pixel services providing Google Analytics integration.

Your Answer

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

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