Adding the audio player through Google Tag Manager: one tag, the right trigger, and the trade-off
Locked template, but you control Google Tag Manager? The audio player can be deployed as a single Custom HTML tag. The exact setup, why the DOM Ready trigger matters, and the two limits to accept before going this way.
Plenty of websites are built so that the people who write the content cannot touch the page template. An agency owns the theme, every change is a ticket, and a new line in the page header can take a sprint or two. Meanwhile someone in marketing has had admin access to Google Tag Manager for years, because that is how analytics got installed in the first place.
So the question is a fair one: can the audio player go in through Tag Manager, today, without waiting for the agency? It can. This article explains how, what in the player's code makes one particular setting important, and the two downsides that make Tag Manager a good stopgap rather than the ideal final setup.
The one-line script, and why it suits Tag Manager
On any site, the player is installed with a single script tag, player.js. It comes in two forms:
- per article, with a
data-articleattribute pointing at one specific audio; - site-wide, with a
data-siteattribute carrying your account identifier.
The site-wide form is the one to use here. On every page it runs on, the script asks which audio matches the page address (the canonical URL if the page declares one, the visible URL otherwise). If there is an audio, the player appears. If there is none, the script inserts nothing at all, not even an empty frame. That is precisely the kind of tag Tag Manager is designed to deploy: identical on many pages, without editing any of them. The script reads its settings from its own tag, and Tag Manager keeps those attributes when it injects a Custom HTML tag.
Setting it up
1. In your container, create a tag of type Custom HTML.
2. Paste the site-wide line shown on the Install on my site screen of your dashboard:
<script src="https://wedispatch.fr/player.js" data-site="YOUR_ID" defer></script>
3. Fire it on a DOM Ready trigger, restricted to article pages (for instance, Page Path contains /news/ or /blog/).
4. Use Preview, open an article that already has its audio, check that the tag fired and the player sits where you expect, then publish the container version.
If your site runs WordPress, skip all of this: the WordPress plugin places the player without editing the theme and without Tag Manager. The Tag Manager route is for sites where the template really is out of reach.
Why DOM Ready, and not the default page view trigger
This is the setting that decides whether the result looks right, and it follows directly from how player.js is written. The script picks its position at the moment it runs; it does not wait for the page to finish building. Its order of preference:
1. a reserved slot, <div data-wedispatch></div>, if the page contains one;
2. otherwise the first real article paragraph: in the normal page flow, visible, wide enough and long enough to be prose. This rule exists because on many European sites the first paragraph in the document belongs to the cookie banner, and the player once ended up inside one;
3. as a last resort, the very top of the page body.
Tag Manager's default trigger fires early, sometimes before the article body has reached the browser. The script then finds no paragraph and falls back to the top of the page, above your site header. On DOM Ready the document has been parsed, the first paragraph exists, and the player lands just before it.
For a precise position (under the standfirst, under the lead photo), the reserved slot still works through Tag Manager: drop a <div data-wedispatch></div> into an HTML block in your editor and the script will prefer it over anything else. Some editors silently strip empty blocks; if yours does, rely on the paragraph search, which is what most sites use anyway.
What you get for free
The player reports each listen as an event prefixed wedispatch_, pushed to the dataLayer whenever the page has one. With Tag Manager already on the page, the only work left is to create the triggers that pick those events up. The full event list and the GA4 setup are in tracking audio listens in Google Analytics 4 or Matomo.
On consent: the player sets no cookie on your domain and calls no third-party tracker, so there is no technical reason to hold this tag behind an analytics consent signal. That remains your call; what the player does store is described in does the audio player set cookies?.
If your site sends a Content-Security-Policy, it applies to tags injected by Tag Manager like any other. In site-wide mode the player needs https://wedispatch.fr allowed in script-src, frame-src and connect-src; the details, including nonces, are in the audio player and Content-Security-Policy.
The trade-off
Visitors who block Tag Manager will not see the player. Several widely used blocklists stop Tag Manager itself from loading, since its main job is analytics. Anything it carries goes with it. For a feature that is partly about accessibility, that matters: someone running a blocker is no less likely to need the audio than anyone else. This is the main reason to treat Tag Manager as the way to get started while the template change is scheduled, not as the permanent installation.
The player shows up a little later. It waits for the page to be parsed, then for the answer saying whether this address has an audio (that answer is cached for two minutes, so a returning visitor does not ask again). As soon as an audio is found, a placeholder with the player's exact dimensions takes its place, so the text does not jump. For readers who came to read, the delay goes unnoticed; it is simply worth knowing.
One practical trap: site-wide mode finds the audio by page address. If the page declares a canonical URL that differs from the one the article was voiced under (an old domain, a stray parameter), the lookup returns nothing. Preview mode makes this obvious: the tag fired, and no player appeared.
The short version
Locked template, working Tag Manager: one Custom HTML tag, the site-wide form of the script, a DOM Ready trigger limited to article pages, a check in Preview. Accept that visitors who block Tag Manager lose the player, and plan to move the script line into the template when the agency gets to it. On that day you pause the tag, and nothing else changes.
Give your articles a voice with WeDispatch
This blog is itself voiced by WeDispatch. Curious how it sounds on your content?
Book a demo