Form Event Tracking
Form event tracking allows you to monitor when customers view and submit your forms. This data helps you understand form performance, conversion rates, and user behavior.
What is Form Event Tracking?
Section titled âWhat is Form Event Tracking?âForm tracking fires custom JavaScript events that you can capture with analytics platforms like:
- Google Analytics (GA4)
- Google Tag Manager
- Facebook Pixel
- Meta Pixel
- TikTok Pixel
- Hotjar
- Any custom analytics solution
Available Events
Section titled âAvailable Eventsâ| Event | Description | Use Case |
|---|---|---|
| Form View | Fires when a customer sees the form | Track form impressions, page views |
| Form Submit | Fires when a customer successfully submits | Track conversions, lead generation |
Enabling Event Tracking
Section titled âEnabling Event TrackingâStep 1: Enable Tracking Options
Section titled âStep 1: Enable Tracking Optionsâ- Open your form in the Form Builder
- Go to the Scripts tab in the left panel
- Enable the tracking options you need:
Track Form View
Section titled âTrack Form Viewâ- What it does: Fires an event when the form loads on the page
- Event name:
qivra_form_view - Event data: Includes form ID and form name
Track Form Submit
Section titled âTrack Form Submitâ- What it does: Fires an event after successful submission
- Event name:
qivra_form_submit - Event data: Includes form ID, form name, and submission ID
Step 2: Get Your Tracking Code
Section titled âStep 2: Get Your Tracking Codeâ- Enable at least one tracking option
- Click Get tracking setup code
- Copy the provided JavaScript snippet and Click here to open it
- Add it to your themeâs custom JavaScript or use a tag manager
Understanding the Tracking Code
Section titled âUnderstanding the Tracking CodeâThe generated tracking code looks like this:
// Listen for form view eventswindow.addEventListener('qivra_form_view', function(event) { const { formId, formName } = event.detail;
// Send to your analytics platform // Example: gtag('event', 'form_view', { form_id: formId, form_name: formName });});
// Listen for form submit eventswindow.addEventListener('qivra_form_submit', function(event) { const { formId, formName, submissionId } = event.detail;
// Send to your analytics platform // Example: gtag('event', 'form_submit', { form_id: formId, form_name: formName });});Event Data Structure
Section titled âEvent Data StructureâEach event includes:
| Property | Type | Description |
|---|---|---|
formId | String | Unique identifier for the form |
formName | String | Name of the form |
submissionId | String | Unique submission ID (submit event only) |
Integration Examples
Section titled âIntegration ExamplesâGoogle Analytics 4 (GA4)
Section titled âGoogle Analytics 4 (GA4)âwindow.addEventListener('qivra_form_view', function(event) { gtag('event', 'form_view', { form_id: event.detail.formId, form_name: event.detail.formName });});
window.addEventListener('qivra_form_submit', function(event) { gtag('event', 'generate_lead', { form_id: event.detail.formId, form_name: event.detail.formName });});Google Tag Manager
Section titled âGoogle Tag Managerâwindow.addEventListener('qivra_form_view', function(event) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'qivra_form_view', form_id: event.detail.formId, form_name: event.detail.formName });});
window.addEventListener('qivra_form_submit', function(event) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'qivra_form_submit', form_id: event.detail.formId, form_name: event.detail.formName });});Then in GTM, create triggers for:
- Custom Event:
qivra_form_view - Custom Event:
qivra_form_submit
Facebook/Meta Pixel
Section titled âFacebook/Meta Pixelâwindow.addEventListener('qivra_form_view', function(event) { fbq('trackCustom', 'FormView', { form_id: event.detail.formId, form_name: event.detail.formName });});
window.addEventListener('qivra_form_submit', function(event) { fbq('track', 'Lead', { content_name: event.detail.formName, content_id: event.detail.formId });});TikTok Pixel
Section titled âTikTok Pixelâwindow.addEventListener('qivra_form_submit', function(event) { ttq.track('SubmitForm', { content_id: event.detail.formId, content_name: event.detail.formName });});Adding the Tracking Code
Section titled âAdding the Tracking CodeâMethod 1: Theme Custom JavaScript
Section titled âMethod 1: Theme Custom JavaScriptâ- Go to Online Store > Themes
- Click ⌠> Edit code
- Find or create
assets/custom.js - Paste your tracking code
- Save the file
Method 2: Using a Script Manager App
Section titled âMethod 2: Using a Script Manager AppâIf you use a script manager app (like Script Manager, TinyIMG, etc.):
- Open your script manager app
- Add a new script
- Set it to load on pages with forms
- Paste your tracking code
- Save and publish
Method 3: Shopify Theme Settings
Section titled âMethod 3: Shopify Theme SettingsâSome themes allow custom JavaScript in theme settings:
- Go to Online Store > Themes > Customize
- Go to Theme Settings > Custom JavaScript
- Paste your tracking code
- Save
Method 4: Direct in Theme Layout
Section titled âMethod 4: Direct in Theme LayoutâFor advanced users:
- Go to Online Store > Themes > Edit code
- Open
layout/theme.liquid - Add before
</body>:
<script>// Your tracking code here</script>- Save
Testing Your Tracking
Section titled âTesting Your TrackingâVerify Events are Firing
Section titled âVerify Events are Firingâ- Open your form page
- Open browser DevTools (F12)
- Go to Console tab
- Add this to test:
window.addEventListener('qivra_form_view', (e) => console.log('Form viewed:', e.detail));window.addEventListener('qivra_form_submit', (e) => console.log('Form submitted:', e.detail));- Reload the page and submit the form
- Check console for event logs
Verify in Analytics Platform
Section titled âVerify in Analytics PlatformâAfter setup, verify events are being received:
| Platform | How to Verify |
|---|---|
| GA4 | Realtime > Events report |
| GTM | Preview mode |
| Facebook Pixel | Events Manager |
| TikTok | Events Manager |
Common Use Cases
Section titled âCommon Use CasesâTrack Conversion Rate
Section titled âTrack Conversion RateâCalculate form conversion rate by comparing:
Conversion Rate = (Form Submits / Form Views) Ă 100Track Form Performance by Page
Section titled âTrack Form Performance by PageâUse formName to compare performance across different pages.
Track Funnel Steps
Section titled âTrack Funnel StepsâCombine form view/submit with page view events to build conversion funnels.
Remarketing Campaigns
Section titled âRemarketing CampaignsâCreate custom audiences based on form views (not submitted) or leads (submitted).
Troubleshooting
Section titled âTroubleshootingâEvents Not Firing
Section titled âEvents Not Firingâ- Check if tracking is enabled: Scripts tab toggles must be ON
- Verify script placement: Script must load after the form
- Check browser console: Look for JavaScript errors
- Test in preview mode: Some analytics donât work in preview
Events Not Appearing in Analytics
Section titled âEvents Not Appearing in Analyticsâ- Verify event names: Match exactly what your analytics expects
- Check data format: Ensure event data matches your setup
- Allow time for processing: Some platforms have delays
- Check ad blockers: Can block analytics scripts
Script Conflicts
Section titled âScript ConflictsâIf you have multiple tracking scripts:
- Use unique names for your event listeners
- Check for conflicts with other scripts
- Test individually to isolate issues
- Consider event delegation for multiple forms
Best Practices
Section titled âBest PracticesâPerformance
Section titled âPerformanceâ- Load asynchronously: Donât block page load
- Defer non-critical tracking: Load after main content
- Test impact: Monitor page load times
Privacy
Section titled âPrivacyâ- Comply with GDPR: Inform users about tracking
- Respect consent: Only track if user consents
- Anonymize data: Donât collect personal info in events
- Use cookie consent: Integrate with cookie banners
Reliability
Section titled âReliabilityâ- Test regularly: Events can break with code changes
- Monitor data: Check for sudden drops in events
- Have backups: Use multiple tracking methods for key events
- Document setup: Keep notes on your tracking configuration