Tracking events in Google Analytics via GTM
Setting up GTM tracking
To enable GTM tracking for your widget:
- Go to your widget settings
- Enable the "Google Tag Manager" toggle
- Enter your GTM container ID (e.g., GTM-XXXXXX)
- Save your changes
Available events
The following events are tracked when GTM is enabled:
- leadcube_interaction (category: widget)
- action: "open" - Triggered when a user opens the widget
- action: "close" - Triggered when a user closes the widget
- leadcube_interaction (category: module)
- action: "open" - Triggered when a module is opened
- action: "close" - Triggered when a module is closed
- action: "cta_click" - Triggered when a CTA button is clicked (includes button_text)
- action: "video_play" - Triggered when a video starts playing (includes video_id)
- action: "call_click" - Triggered when a direct call button is clicked (includes phone_number)
- action: "faq_question_open" - Triggered when a FAQ question is opened (includes question_id and question_text)
- action: "faq_group_open" - Triggered when a FAQ group is opened (includes group_id and group_name)
- leadcube_conversion (category: module)
- action: "form_submit" - Triggered when a form is submitted (includes success status and error_message if applicable)
- action: "whatsapp_send" - Triggered when a WhatsApp message is initiated
Event data
Each event includes the following data:
- event - The event name (leadcube_interaction or leadcube_conversion)
- category - The category (widget or module)
- action - The specific action that occurred
- widget_code - Your widget's unique identifier
- module_type - The type of module (for module events)
- module_code - The module's unique identifier (for module events)
- If applicable, additional data specific to each event type.
Setting up triggers in GTM
To track these events in GTM:
- Create a new trigger for each event you want to track
- Set up the appropriate tags (e.g., Google Analytics 4)
- Configure your variables to capture the event data
Google Analytics 4 Integration
When you enable GTM tracking, all events are automatically sent to Google Analytics 4 (GA4) when configured in your GTM container. This allows you to:
- Track widget and module engagement
- Measure conversion rates
- Analyze user behavior
To get started with GTM and GA4:
- Set up Google Tag Manager on your website
- Create a GA4 property if you haven't already
- Configure GA4 in GTM
Note: Make sure your GTM container is properly set up on your website and connected to GA4 before enabling GTM tracking in the widget.