Track Lexy games in your own analytics
Game starts, answers and scores as Google Tag Manager events and page events, each describing the game.
Your Lexy reports show every play. If your team also measures your site in Google Tag Manager, Google Analytics or another tool, the widget can tell that tool what readers do in a game too. That covers when they start, how each answer goes, and how they finish.
It works on its own. Once the widget is on a page, it sends these events to that page.
What the widget sends
The widget sends each event in two ways at once:
- To Google Tag Manager: a push to the page's
dataLayer, under the event name in the first column. - As a page event: a
lexy:event on the page, for your own scripts. Its name is in the second column.
| Event name (Tag Manager) | Page event | When it happens |
|---|---|---|
lexy_play_click | lexy:play_click | A reader presses Play on a game card. |
lexy_game_start | lexy:game_start | A game starts on the page, in web play or when the gated card opens. |
lexy_call_start | lexy:call_start | A reader uses Call Now to Play and Lexy places the call. The game then carries on by phone, and its answers and score appear in your Lexy stats. |
lexy_answer | lexy:answer | A reader answers a question, by tapping or out loud. |
lexy_game_complete | lexy:game_complete | A reader reaches the score screen. |
lexy_game_exit | lexy:game_exit | A reader closes a game before the end. |
What each event carries
| Tag Manager field | Page event field | What it is |
|---|---|---|
lexy_widget_id | widgetId | The widget's number, as on My Widgets. |
lexy_game_id | gameId | The game's number. The gated card's questions come from the page itself, so its events carry the page's title instead. |
lexy_game_title | title | The game's title, or the page's title on the gated card. |
lexy_lang | lang | The game's language: en, es, tr or ar. |
lexy_surface | surface | Where it happened: card (a game card), modal (the game window), gated (a gated card in the article) or overlay (a gated card in the corner). |
lexy_play_method | method | online or phone. |
lexy_question | question | Which question, counting from 1. On lexy_game_exit, the question the reader had reached. |
lexy_total | total | How many questions the game has. |
lexy_correct | correct | On lexy_answer: true if the answer was right. |
lexy_score | score | Answers right so far. |
lexy_percent | percent | The score as a share of the questions, 0 to 100. |
Each event carries the fields that fit it, for example lexy_correct on an answer.
Every event describes the game, with its title, the question, the answer and the score.
Use them in Google Tag Manager
- In Tag Manager, go to Triggers and click New. Choose Custom Event.
- For Event name, enter one of the names above, for example
lexy_game_complete. To catch every Lexy event with one trigger, enterlexy_.*and tick Use regex matching. - Go to Variables, click New under User-Defined Variables and choose Data Layer Variable. Enter a field name, such as
lexy_score. Make one for each field you want. - Make a tag that uses the trigger, for example a Google Analytics: GA4 Event tag. Set its event name to
{{Event}}and add the variables you made as parameters. - Preview, play a game on your page, and check the events in the preview panel. Then publish the container.
Use them in your own scripts
Every event is also a page event, so your own code can listen to it directly:
document.addEventListener('lexy:game_complete', function (e) {
console.log(e.detail.title, e.detail.score + ' of ' + e.detail.total);
});
Listen on document to hear every Lexy widget on the page. With more than one, e.detail.widgetId tells them apart.
Know when a gated card's questions are ready
A gated card opens its questions as the reader reads, listens or watches. Each time the number of ready questions changes, the widget tells the page with a page event named lexy:questions_ready. Use it to show your own cue, such as a "Quiz ready" badge beside the headline.
| Page event field | What it is |
|---|---|
widgetId | The widget's number, as on My Widgets. |
surface | gated (a gated card in the article) or overlay (a gated card in the corner). |
lang | The questions' language: en, es, tr or ar. |
ready | How many questions the reader can play now. |
locked | How many open later, as the reader reads, listens or watches. |
total | How many questions the card has. |
document.addEventListener('lexy:questions_ready', function (e) {
var badge = document.getElementById('quiz-badge');
badge.textContent = e.detail.ready + ' of ' + e.detail.total + ' ready';
});
This one is sent as a page event only, so your Tag Manager event counts stay as they are. A script that loads after the widget can read the latest count from a gated card in the article: document.querySelector('lexy-widget').lexyQuestionsReady.
A widget in Overlay mode sends the same event from its corner prompt, with surface set to overlay, before the quiz is opened as well as during it.
Know when the corner prompt shows
A widget in Overlay mode puts a small Play the quiz prompt in the corner of the page, or on the video. See Float a quiz over the page or the video. The widget tells the page when the prompt appears and when it goes away, with two page events.
| Page event | When it happens |
|---|---|
lexy:prompt_shown | The prompt appears. It stays for the rest of the visit, so this is sent once per page view unless your own script hides and shows it. |
lexy:prompt_hidden | The prompt goes away, because your script hid it or the reader finished the quiz. |
| Page event field | What it is |
|---|---|
widgetId | The widget's number, as on My Widgets. |
why | On lexy:prompt_shown, what brought the prompt up: ready (a question the reader can play), now (the page has questions), watched (the set time watched), pause (the video paused), end (the video ended) or manual (your script). On lexy:prompt_hidden: manual (your script) or complete (the quiz is finished). |
ready | On lexy:prompt_shown: how many questions the reader can play now. |
locked | On lexy:prompt_shown: how many open later. |
total | On lexy:prompt_shown: how many questions the quiz has. |
lang | The questions' language: en, es, tr or ar. |
document.addEventListener('lexy:prompt_shown', function (e) {
console.log('Quiz prompt shown: ' + e.detail.why, e.detail.ready + ' ready');
});
These two are page events only, like lexy:questions_ready. When the reader taps Not now, the prompt folds to a small mark in the same place and stays on the page, so that sends neither event.
A script that starts listening late can read the last lexy:prompt_shown detail from the widget's tag, as lexyPrompt.
Your page can also show, hide and open the prompt itself. See Control the quiz prompt from your own page.
Send page events only
To send page events only and leave your dataLayer to your own tags, add this line to the page before the Lexy script tag:
<script>window.LexyWidget = { dataLayer: false };</script>
The page events still fire, so your own scripts keep working.
Good to know
- Lexy's reports stand on their own. Your stats on lexy.fm are complete whatever your tags do.
- The events are yours. What your tags do with them stays with you.
- They follow the page. A game opened from a share link or a QR code plays on lexy.fm, and counts in your Lexy stats.
Thanks for letting us know.
Thanks. Write to support@lexy.fm with what you were looking for, and we will answer and improve this page.