You are reviewing MouseStats documentation: Take a look to the product!
< back

Google Analytics integration

Integration of MouseStats and Google Analytics leads to more valuable reports. Google Analytics will provide you brilliant details about visitors. Now, using MouseStats integration you can find out how they are navigating and watch them to answer all the "why" questions.


Goal

By implementing Google Analytics integration, you can:
  • Find valuable users in GA(Google Analytics)
  • Copy their MouseStats Playback Visitor ID from GA
  • and, watch their Playbacks in MouseStats.

MouseStats Playback Visitor ID will be defined as Custom Variable/Custom Dimension in GA reports. So, you can go for segmentation and find valuable users in GA and then watch their Playbacks in your MouseStats account.


How?

The
  • method would be different if you are using Google Analytics viaintegration Googlewithout TagGTM
  • Manager. You need to go for the related instruction in the following.


    If you are using Google Analytics Tracking Code without GTM

    1. First of all, make sure you have Google Universal Analytics. Update your Google Analytics Tracking Code to Universal Analytics.

    2. Add the following code before MouseStats tracking script:

    
    <script type='text/javascript'>
    window.onMouseStatsPlaybackStartRecording = function () {
        ga('set', 'dimension1', MouseStatsVisitorPlaybacks.visitorId());
    }
    </script>
    //MouseStats tracking script here
    

    (Make sure to change dimension1 if you already used this dimension before in GA.)

    3. Create a Custom Dimension in Google Analytics. Make sure the Scope of dimension is "User". Choose a name like "MouseStats Visitor Id".

    New Custom Dimension


    4. After a while, you can find "MouseStats Visitor Id" in "Second Dimension" of any report in GA.

    Reporting


    5. Copy the "MouseStats Visitor Id", and find Playbacksintegration using Visitor Id in filters in MouseStats.

    GTM
  • Visitor Id




    Enabling with Google Tag Manager(GTM) Only

    1. Create a custom HTML tag that fires on All Pages:

    
    <script type='text/javascript'>
    window.onMouseStatsPlaybackStartRecording = function () {
      dataLayer.push({
         'event': 'MousestatsPlayback',
         'Mousestats Visitor ID': MouseStatsVisitorPlaybacks.visitorId()
       });
    }
    </script>
    //MouseStats tracking script here
    

    This script utilizes the dataLayer rather than the global ga() function. It also includes an event object that will tell GTM when it’s supposed to access this information.


    2. Create a Data Layer Macro for 'Mousestats Visitor ID'.


    3. Create a GA Event Tag that fires when event equals 'MousestatsPlayback'. This event can have any category, action and label that the user wants, but this tag will be where you set your User Level custom dimension. So:
    a) Go to GA (Google Analytics)
    b) Create a new dimension (for example slot 1), name it 'Mousestats Visitor ID' and set the scope to User.

    Then, in this event tag, add the custom dimension with the index you’ve chosen (1) and the macro you created earlier as the value:

    Since the scope of your Dimension is User Level, this dimension will be applied to all users that included sessions that included this specific Event hit.