Search code examples
javascriptgoogle-analyticsembedanalytics

Can Google Analytics track conversions inside a JS widget on a 3rd party site?


I'm working on a project that includes a javascript widget that can be wrapped around a video to enable subtitles. I'd like to track clicks when a person has the tool embedded on their site, in order to optimize UX.

Does anyone know if this is possible?


Solution

  • Custom Variables are likely not the route you want to go. They don't make their own calls; they are packaged along with other requests. That is, you'd set a custom variable to signify a single state for a whole page, session or lifetime, not for particular events. Like, for example, if you want to assign a variable to users who are logged in, so you can segment their behavior easily.

    What you're looking for is Event Tracking. They behave somewhat like pageviews, but they have up to 4 data points allowed (category, action, label, and value). This allows you to do things like pass the video's time stamp, track particular actions like enable/disable captions, play, pause, etc. And, with secondary dimensions and advanced segmentation, they offer just as much customization as custom variables.