Before you start
- The allGood tag is installed on the page. See Install the tag.
- You can edit the page’s HTML, or add a Custom HTML tag in Google Tag Manager.
- You’ve read the short Identify and track reference for the
track()call.
What the tag can and can’t see
The tag watches the page it’s on. It sees the page load, route changes in a single-page app, and submissions on forms you’ve pointed at allGood. It can’t see two kinds of thing:- Anything inside an iframe. Video players, chat widgets, embedded demos and scheduling tools usually run in an iframe served from another domain. The browser keeps that content separate from your page.
- Anything that doesn’t load a page or submit a form. Opening a tab, moving a slider in a calculator, or expanding an FAQ changes the page without the tag noticing.
track(). Each call becomes an activity on the visitor’s record, and allGood connects it to the person once they’re identified.
For a video player or any other tool, use the pattern below.
The pattern
Every custom event comes down to four moves:- Find the thing. Locate the element or widget on the page: an iframe, a button, a calculator’s form.
- Listen to what it reports. Most embedded tools publish a JavaScript API with events such as
play,messageorsubmit. For your own page elements, use ordinary DOM events likeclickandchange. - Decide which moments matter. Don’t forward everything. Pick the few moments a marketer would act on, and send each one once.
- Send it with
track(). Use a clear event name and a consistent set of properties.
Worked example: who’s watching a video
A marketer wants to know who watched a recording and how far they got. That breaks down into three moments worth sending:
allGood turns each event name into an activity type, so
Video Played becomes video.played. Here’s how to build it for a Vimeo player.
1
Add the queue stub above the tag
Make sure this line sits above the allGood tag:The tag loads asynchronously, so your code may run before it’s ready.
window.agq is a queue: anything you push onto it is sent once the tag loads, and pushes after that are sent straight away. You never have to check whether the tag has loaded. This applies to every custom event, not just video.2
Load the tool's JavaScript API
For Vimeo, that’s the Player SDK. Add it after the tag, without Most embedded tools have an equivalent: a script that lets your page talk to the iframe. Look for “JavaScript API”, “Player SDK” or “embed API” in the vendor’s developer docs.
async:3
Find the thing: connect to every player on the page
Place this script after the iframes, for example just before Selecting every matching iframe, not just the first one on the page, means three videos are all tracked and a page with none does nothing. Wrapping the code in a function keeps its variables from clashing with other scripts.
</body>:4
Look up the details you'll send with every event
Ask the player for the video’s ID, title and length, once:Many tool APIs, Vimeo’s included, return promises: the answer arrives a moment later, so reading it on the next line gets nothing. Storing the promise and waiting on it before each send avoids that bug. The
.catch keeps events flowing, just without a title, when a video’s privacy settings block the lookup.5
Send it: write one helper for track()
url: the tag doesn’t know which page a custom event came from unless you send it, and it pulls UTM parameters out of that URL.6
Listen, and decide: send Video Played once
play every time playback starts, including each resume after a pause. That’s the “decide which moments matter” move: the played flag turns a noisy signal into one meaningful event per page load.7
Listen, and decide: send each milestone once
timeupdate fires about four times a second. Sending all of those would bury the useful signal, so the code sends only when a milestone is first crossed. A viewer who skips ahead past 50% sends 25 and 50 together.8
Send Video Completed
9
Watch the requests go out
Open the page with your browser’s developer tools on the Network tab, then play the video. You’ll see a request to your allGood domain shortly after it starts, another at 25%, and a final one at the end.
10
Confirm on a person's record
Submit a form on the same page with a test email, then find that person in allGood.
Video Played, a Video Progressed for each milestone passed, and Video Completed on the person’s timeline, each with the video’s title. Views from before the form fill appear too, because allGood connects earlier anonymous activity to the person once they identify themselves.
The complete Vimeo script
Apply the pattern to other tools
The four moves stay the same. Only what you listen to changes.
Each row works the same way as the video example: find it, listen, keep only the moments that matter, and send them through one helper.
Name events so they stay useful
- Use
Object Verbed, in title case:Video Played,Demo Requested. This matches the convention in Identify and track. - Keep one name per kind of moment, and put the details in properties.
Video Progressedwithpercent: 50beatsVideo 50 Percent, which becomes a separate activity type for every milestone. - Reuse names across tools. If two players both send
Video Playedwith avideoProviderproperty, one report covers both. - Don’t put personal data in properties or URLs. Identify people with
identify()or a form, not by stuffing an email into an event.
Replacing a Munchkin snippet
Munchkin had no custom events, so pages that tracked these actions for Marketo usually faked a page visit, such asvisitWebPage('/video/76979871', 'video=finished'). Remove those calls and send real events instead. Any Marketo Smart Campaign that filtered on the made-up URLs needs rebuilding against the new activities.
Troubleshooting
Nothing reaches allGood. Check Send events to allGood in Web Tracking settings first. If it’s on, check consent: custom events wait until your consent platform answers, and are dropped on a no. See Two settings can silence these. The tool’s object is undefined, such asVimeo is not defined. Its API script hadn’t loaded when your code ran. Load it without async, above your script.
Events arrive without details. The tool refused a lookup, often because of privacy or embed settings on the vendor’s side. Check those settings.
Events arrive twice. The script is on the page twice, often once in the page and once in GTM. Keep one.
If you’re still not seeing events after working through these, contact allGood support or your allGood team, and include the page URL and a screenshot of the Network tab after the action.
Related articles
- Identify and track: the
track()andidentify()reference - Install the tag
- What consent gates
- Test your setup
- Vimeo Player SDK