Standard GA4 Event Tags w/ paramaters
1. Standard Google Events with GA4 Initialization- GA4 Initialization: When you initialize GA4 (typically using a GA4 Configuration Tag in GTM or directly through the GA4 code snippet on your site), GA4 automatically tracks a set of standard events. These include:
- page_view: Tracked whenever a page loads or the history state is changed.
- scroll: Tracked when the user scrolls to 90% of the page.
- click: Tracked when the user clicks on a link.
- session_start: Tracked when a new session begins.
- user_engagement: Tracked periodically during the session as long as the user is interacting with the page.
- Need to Push Through GTM: These standard events are automatically tracked by GA4, and you do not need to push these through GTM. GA4 handles them internally as long as the GA4 Configuration Tag is correctly set up and initialized.
1. page_view
• Tracks: page_location, page_referrer, page_title, page_path
• Use: This event is fundamental for tracking any page load. Parameters like page_path or page_title can be renamed to track specific pages or groups of pages.
2. scroll
• Tracks: percent_scrolled
• Use: Automatically tracks when a user scrolls to 90% of the page. You can rename the scroll depth parameter to track scrolling on specific pages or sections.
3. session_start
• Tracks: session_id, engagement_time_msec
• Use: Great for tracking when a user session begins. Additional parameters could be added or renamed to track specific session start conditions or sources.
4. user_engagement
• Tracks: engagement_time_msec, page_location
• Use: Captures user engagement across sessions. Rename parameters to filter by specific pages or user states for detailed engagement analysis.
5. click
• Tracks: link_url, link_text
• Use: Useful for tracking clicks on links or buttons. Rename link_url or link_text to categorize or filter clicks on specific elements or actions.
6. file_download
• Tracks: file_name, file_extension, file_url
• Use: Tracks when users download files. You can rename parameters to differentiate between types of files or to track specific files separately.
7. view_search_results
• Tracks: search_term
• Use: Automatically triggered when search results are viewed. You can rename the search_term parameter to categorize searches by different types or sections of your site.
8. video_start
• Tracks: video_title, video_url
• Use: Triggered when a video starts playing. Rename parameters to differentiate between types of videos or specific video content.
9. video_progress
• Tracks: video_title, video_url, percent_progress
• Use: Tracks the progress of a video. You can rename the percent_progress parameter to track progress milestones or focus on specific content.
10. video_complete
• Tracks: video_title, video_url
• Use: Triggered when a video is completed. Rename parameters to analyze completion rates of different videos or video types.
Additional Noteworthy Standard Events:
• outbound_click
• Tracks: link_url
• Use: Tracks clicks on links leading outside your domain. Rename link_url to categorize different types of outbound links.
• form_submit
• Tracks: (Custom parameters typically added)
• Use: Triggered when a form is submitted. While this event doesn’t track many parameters by default, you can add and rename parameters to capture specific form interactions.
• purchase
• Tracks: transaction_id, value, currency, items[]
• Use: Tracks a purchase on your site. Rename parameters within the items array to differentiate between products or product categories.
How to Use These Standard Events:
• Renaming Parameters: For each of these standard events, you can rename the parameters to provide additional context specific to your business needs. This allows for more granular analysis without needing to create a custom event.
• Filtering and Segmentation: In GA4, you can use these renamed parameters to filter data in reports, create segments, or build custom audiences.
Summary:
By leveraging these standard GA4 events and strategically renaming or adding parameters, you can effectively filter and analyze your data without the need for excessive custom events. This approach helps you maintain a streamlined analytics setup while still getting detailed insights into user behavior.
EXIT EVENT
Tracking exit events in GA4 (i.e., capturing when users leave your site) is inherently challenging because web browsers don’t provide a direct way to detect when a user closes a tab, navigates away, or otherwise exits the site. However, there are some methods to approximate and track user exits with reasonable accuracy. Below are the most accurate and simplest ways to achieve this:
1. Use of session_end
in GA4
- What It Is: GA4 doesn’t have a built-in
session_end
event like Universal Analytics used to. Instead, GA4 infers the end of a session based on inactivity (30 minutes by default). - How to Use: Although you can’t directly track an exit event, you can infer exits by looking at the last event in a user’s session. In reports, you can filter or segment sessions by the last event to approximate exit points.
2. Using beforeunload
Event in JavaScript
What It Is: The
beforeunload
event in JavaScript is triggered just before the user is about to leave the page, either by closing the tab, navigating to another page, or refreshing the page.Implementation:
window.addEventListener('beforeunload', function (event) { gtag('event', 'exit', { 'event_category': 'User Exit', 'event_label': document.location.pathname, 'value': 1 }); });
Accuracy: This method is fairly accurate but not foolproof. It can sometimes be bypassed if the user’s browser blocks or cancels the event, and it won’t trigger in all scenarios (e.g., abrupt browser closure, power loss).
Simplicity: This is one of the simplest ways to approximate exit tracking with a single script.
3. Tracking Time on Last Page
What It Is: By tracking the time spent on the last page viewed in a session, you can infer potential exit points. If the time on a specific page is significantly longer than average, it might indicate that the user left from that page.
Implementation:
- Use the
user_engagement
event in GA4, which already tracks time spent on the page. Then, analyze sessions where theuser_engagement
event is the last event before inactivity.
- Use the
Accuracy: This method provides an indirect way to estimate exits, but it relies on analyzing session data rather than capturing a precise exit event.
Simplicity: It’s simple from an implementation standpoint since GA4 handles most of the data collection automatically.
4. Enhanced beforeunload
with Idle Tracking
What It Is: Combines the
beforeunload
event with idle tracking to better estimate when a user might be exiting the site.Implementation:
- Use JavaScript to detect when a user has been idle (no mouse movements, keypresses, or interactions) for a certain period, then trigger an event that marks a potential exit.
- Pair this with
beforeunload
to track when the user is definitely leaving the site.
let idleTime = 0; function resetIdleTimer() { idleTime = 0; } window.onload = resetIdleTimer; document.onmousemove = resetIdleTimer; document.onkeypress = resetIdleTimer; setInterval(function() { idleTime++; if (idleTime >= 30) { // 30 seconds of idle time gtag('event', 'idle_exit', { 'event_category': 'User Exit', 'event_label': document.location.pathname, 'value': 1 }); } }, 1000); // check every second window.addEventListener('beforeunload', function (event) { gtag('event', 'exit', { 'event_category': 'User Exit', 'event_label': document.location.pathname, 'value': 1 }); });
Accuracy: Improves accuracy by combining idle detection with the
beforeunload
event, but still not 100% reliable due to limitations in browser behavior.Simplicity: More complex than just using
beforeunload
alone but provides better coverage.
5. Using a Timer-Based Approach
What It Is: Set a timer that sends an event if the user has been inactive on a page for a certain period (e.g., 2 minutes).
Implementation:
let exitTimer = setTimeout(function() { gtag('event', 'potential_exit', { 'event_category': 'User Exit', 'event_label': document.location.pathname, 'value': 1 }); }, 120000); // 2 minutes document.onmousemove = document.onkeypress = function() { clearTimeout(exitTimer); exitTimer = setTimeout(function() { gtag('event', 'potential_exit', { 'event_category': 'User Exit', 'event_label': document.location.pathname, 'value': 1 }); }, 120000); };
Accuracy: Less accurate as it can only infer potential exits based on inactivity, but it’s useful for capturing users who leave a tab open without interacting.
Simplicity: Relatively simple to implement, though it may result in some false positives.
Summary of Methods:
beforeunload
Event: Simple and direct, but not foolproof.- Time on Last Page: Uses GA4’s existing
user_engagement
data for inference. - Enhanced
beforeunload
with Idle Tracking: Combines multiple methods for better accuracy. - Timer-Based Approach: Infers exits based on inactivity, simple but less accurate.
Recommendation:
For the simplest and relatively accurate approach, I recommend using the beforeunload
event combined with idle tracking. This method offers a good balance between implementation complexity and accuracy, providing a reasonable approximation of user exits without requiring too much setup.