Javascript: Push Mouseflow Session ID as a Custom Dimension to Google Analytics Through Google Tag Manager
JavaScript: Push Mouseflow Session ID as a Custom Dimension to Google Analytics Through Google Tag Manager
Session tracking is a vital aspect of user behavior analysis, and the integration of Mouseflow and Google Analytics provides valuable insights for marketers and website owners. This article will guide you step-by-step on how to push Mouseflow session ID as a custom dimension to Google Analytics through Google Tag Manager. Here’s an overview of the process:
- Create a custom JavaScript variable in Google Tag Manager.
- Set up a Window Loaded trigger.
- Create a session-scoped custom dimension in Google Analytics.
- Configure an event tag in Google Tag Manager to push the Mouseflow session ID to Google Analytics using the custom dimension.
Step 1: Create a custom JavaScript variable in Google Tag Manager
In Google Tag Manager, navigate to the "Variables" section, and click "New." Provide a name for the variable, such as "Mouseflow Session ID."
Select the "Custom JavaScript" variable type and paste the following code in the fields:
function() {
return mouseflow.getSessionId();
}
This code will return the Mouseflow session ID for the current user. Once the custom JavaScript variable is saved, it’s ready for use in the subsequent steps.
Step 2: Set up a Window Loaded trigger
In Google Tag Manager, navigate to the "Triggers" section, and click "New." Provide a name for the trigger, such as "Window Loaded."
Choose the "Window Loaded" trigger type for the event to be fired, ensuring that the Mouseflow session has been initialized before sending the session ID to Google Analytics.
Step 3: Create a session-scoped custom dimension in Google Analytics
Log in to your Google Analytics account, and navigate to the "Admin" section. Select the property you’d like to add the custom dimension to, and click on "Custom Definitions" under the Property column. Then, click "Custom Dimensions."
Click "New Custom Dimension" and provide a name for the custom dimension, such as "Mouseflow Session ID." Set the scope to "Session" and click "Create."
Take note of the index number assigned to the custom dimension. This value will be required in the next step.
Step 4: Configure an event tag in Google Tag Manager to push the Mouseflow session ID to Google Analytics using the custom dimension
Navigate back to Google Tag Manager, and create a new event tag by clicking on "Tags" and then "New." Provide a name for the tag, such as "GA – Mouseflow Session ID."
Choose the "Universal Analytics" tag type and enter your Google Analytics Tracking ID. Under "Track Type," choose "Event." Provide an event category, action, and label. These values will help identify the events in Google Analytics. For example:
- Category: "Mouseflow"
- Action: "Session ID"
- Label: ""
Under "More Settings," navigate to "Custom Dimensions." Click "Add Row" and input the index number of the custom dimension created in Google Analytics in the "Index" field. In the "Value" field, insert the custom JavaScript variable created in Step 1 by clicking the bracket icon next to the field and selecting the "Mouseflow Session ID" variable.
Assign the "Window Loaded" trigger created in Step 2 to the event tag.
Click "Save" and then publish the changes to the Google Tag Manager container.
Conclusion
Integrating Mouseflow session IDs into your Google Analytics data provides deeper insights into website user behavior, empowering informed decision-making to optimize conversion rates and user experience.
Following these steps, you can seamlessly push Mouseflow session IDs as custom dimensions to Google Analytics through Google Tag Manager. With this set-up in place, you can track, analyze, and utilize session IDs efficiently without the need for additional, time-consuming data processing.
For even further data-driven insights, consider integrating Flowpoint.ai, a web analytics platform that utilizes AI to analyze user behavior, generate recommendations for boosting conversion rates, and offer features such as funnel analytics and easy-to-generate reports. With tools like Mouseflow, Google Analytics, Google Tag Manager, and Flowpoint, you’ll be well-equipped to make data-driven decisions for growth.
Get a Free AI Website Audit
Automatically identify UX and content issues affecting your conversion rates with Flowpoint's comprehensive AI-driven website audit.