Prerequisites
- Google Tag Manager installed on your website
- Your Formbricks Environment ID (Settings > Configuration > Website & App Connection)
- Your App URL:
https://app.formbricks.com(or your self-hosted URL)
Use PUBLIC_URL for multi-domain setups, WEBAPP_URL for single-domain setups.
Basic Setup
1
Create a Custom HTML tag in GTM
- Create a new tag with preferred name e.g. “Formbricks Intercept Surveys”
- Tag Type: Custom HTML
- Paste the code from Step 2. Make sure to replace
<your-environment-id>and if you self-host, replace<your-app-url>
2
Add initialization script

3
Set trigger
- Trigger: All Pages - Page View (default) or use case specific event
- Save and publish

4
Test
- Use GTM Preview mode
- Verify the tag fires
- Add
?formbricksDebug=trueto the URL to see test logs in browser console (see Debugging Mode for more details)
User Identification
Identify users to enable targeting and attributes. Learn more about user identification.User identification is part of the Formbricks Enterprise Edition.
1
Create GTM variables
- Go to Variables on GTM dashboard
- Create new User-defined variable
- Name it (e.g., “User ID”)
- Variable Type: Data Layer Variable
- Data Layer Variable: “userId”
- Save and publish
-
Repeat for attributes you want to track e.g. “userEmail” and “userPlan” (optional)

2
Create identification tag
New Custom HTML tag named “Formbricks - User”:
3
Set trigger and push data
- Create a custom event trigger in GTM
- Trigger Type: Custom Event
-
Event name:
user-login(or your preferred event name) - Attach this trigger to your “Formbricks - User” tag
-
Save and publish

- In your code, push data with the same event name:
Track Custom Events
1
Create code action in Formbricks
Add code action via Formbricks UI

2
Create GTM variable for Event Name
- Go to Variables on GTM dashboard
- Create new User-defined variable
- Name it “Event Name”
- Variable Type: Data Layer Variable
- Data Layer Variable: “eventName”
-
Save and publish

3
Create event tracking tag
New Custom HTML tag:
4
Create custom trigger
- Create a custom event trigger in GTM
- Trigger Type: Custom Event
-
Event name:
eventNameor name that matches with your event in code. - Attach this trigger to your event tracking tag
-
Save and publish

5
Fire events from your site
Troubleshooting
Surveys not showing?- Use GTM Preview mode to check tag firing
- Add
?formbricksDebug=trueto your URL - Check browser console for errors
- Wait 1 minute for the Server Cache to refresh
- Verify Data Layer push syntax
- Check GTM variables are reading correct values
- Ensure user tag fires after initialization
- Confirm
window.formbricksexists before calling track - Match event names exactly with Formbricks action names
- Check timing - Formbricks must be initialized first