All docs pages
Integrations#
TryFast works with the tools already on your page: it tells your tag manager and analytics which variation a visitor saw, it listens to your cookie banner, and any script can react to its window events.
Google Tag Manager and the data layer#
When the project setting dataLayer events is on (the default) and your page has a window.dataLayer array, TryFast pushes:
// when a visitor enters an experiment (once per experiment per page view)
{event: "tryfast_exposure", tryfast_experiment: "free-shipping-headline", tryfast_variation: "b"}
// when a goal fires
{event: "tryfast_conversion", tryfast_goal: "purchase"}
TryFast never creates window.dataLayer; without it nothing is pushed. Nothing is pushed before consent, and never in the exempt consent mode (Privacy and consent).
Send experiments to Google Analytics 4 through Tag Manager#
- In Tag Manager, create two Data Layer Variables:
tryfast_experimentandtryfast_variation. - Create a trigger of type Custom Event with the event name
tryfast_exposure. - Create a Google Analytics: GA4 Event tag named for example
experiment_exposure, with the event parametersexperiment={{tryfast_experiment}}andvariation={{tryfast_variation}}, fired by that trigger. - In GA4, register the two parameters as custom dimensions to compare segments.
The numbers in GA4 will differ from TryFast's: GA4 counts sessions and its own consent and filtering, while TryFast counts each visitor once from their first exposure, with bots and test traffic removed. Use TryFast's results for the decision and GA4 to explore.
Window events#
Every page with the snippet dispatches tryfast:ready, tryfast:exposure, tryfast:conversion and tryfast:aborted on window (JavaScript API). For example, to tag your own analytics or session replay tool:
window.addEventListener("tryfast:exposure", function (e) {
myAnalytics.track("Experiment viewed", {
experiment: e.detail.experiment.key,
variation: e.detail.variation.key
});
});
Consent banners#
With the default consent mode, TryFast waits until your cookie banner says yes. Connect it by calling consent(true) when the visitor accepts, and consent(false) only when they actively decline or withdraw (it clears TryFast's storage). Use the queue form so the call works even when your banner runs before the TryFast script:
window.tryfast = window.tryfast || [];
window.tryfast.push(["consent", true]);
consent(true) is remembered in the visitor's browser, so later pages apply experiments before your banner script has loaded. Assign TryFast to the category your banner uses for statistics, analytics or performance, never to strictly necessary cookies, and list it in your banner's services so visitors can see it.
Ready-made recipes, each a few lines to paste after your banner's script, are in Privacy and consent:
Testing without a banner? Open your site and run tryfast.push(["consent", true]) in the browser console.
Not yet available#
Native connections to analytics tools, webhooks and server-side conversions (sending a conversion from your backend) are planned. Until then, use the data layer, the window events, and tryfast.track() on the confirmation page.