Documentation / Product / Integrations / Google / Google Analytics

Google Analytics: Setup Custom Dimensions

Lytics has the ability to pass all public audiences as a Custom Dimension to Google Analytics out-of-the-box. This allows for global filters based on Lytics audiences to be applied to reports, custom views and nearly every aspect of your existing Google Analytics account.

Integration Details

Configuration

  1. Navigate to Google Analytics in the Integrations section of Lytics. google analytics 215
  2. Select Workflows from the menu on the left.
  3. Select Setup Dimensions from the list.
  4. Select the authorization you would like to use.
  5. From the Choose an Account dropdown, select the account to use. This menu will be populated with all Google Analytics accounts the authorization has access to.
  6. From the Choose a web property dropdown, select the appropriate web property you wish to configure.
  7. Click Start Setup.

Lytics will create two Custom Dimensions within your Google Analytics account. Website visitor information will begin to flow into your Google Analytics account via the Lytics JavaScript tag.

Advanced Configuration

Advanced options are reserved for special cases or advanced users. These configuration steps are not required for the base installation, and Lytics recommends you proceed with caution.

  1. After completing the steps 1-6 above, select Show Advanced Options.
  2. Select existing custom dimensions to pass Lytics audiences into*.
  3. Select existing custom dimensions to pass Lytics User IDs into*.
  4. Select the checkbox Do you have a Google Analytics 360 account? if you have one, which enables you to create up to 200 custom dimensions instead of 20.
  5. Using the Export Fields configuration Lytics has the ability to pass additional data into Google Analytics. Lytics Support should be consulted prior to configuring this field in order to ensure your account will allow for it.

Configure Lytics Audiences in GA

The final step is to configure the display of Lytics audiences within your Google Analytics account. For full details on how to leverage custom dimensions across Google Analytics, please consult Google's documentation.

Create Google Analytics Segments from Lytics Data

  1. From your Audience Overview inside of Google Analytics select Add Segment towards the top. Google Analytics Overview
  2. Select the red + New Segment button at the top of the list of existing Google segments.
  3. Name your segment in the following window. This is what will appear in your reporting and across your Google Analytics interface.
  4. Under Advanced select Conditions. This allows you to create Google Segments from custom dimensions.
  5. Select the dropdown menu that sets the dimension (often this will default to Ad Content) and from the dropdown menu expand Custom Dimensions and click on the Lytics Audiences dimension. Lytics audiences custom dimension
  6. In the text input to the right of contains, type in the ID of your audience. This can be found on the Lytics audience overview next to the full audience name. In the example shown below, mobile_web_visitor would be used as the audience ID. Note: the audiences you use must be API enabled. Audience ID
  7. Save your Google segment. You can now activate or deactivate this segment at any time to filter all aspects of your Google Analytics dashboard. Google Analytics Filter

Lytics Event Override

By default, this integration will fire a Google Analytics event on each page load. This ensures all audience data is associated with the visitor and received by Google. If you would like to prevent this additional event on page load, Lytics offers a custom override that prevents Google Analytics from sending the initial "pageview" event until Lytics audiences have been set properly each time a visitor views a page.

  1. Blacklist the native Google Analytics integration. This is required in order to prevent duplicate events.
  2. Alter the Google Analytics Website Tracking tag. The default Google Analytics Website Tracking tag automatically triggers a "pageview" after it has been loaded. To prevent the additional Lytics event this event call must be removed. To do so, simply remove the following line from the default Google Analytics Website tracking code: ga('send', 'pageview');
  3. Install the following Lytics Google Analytics integration snippet. This code should be located just below your Google Analytics Website Tracking code.

    <script>
        !function(l,a){a.liosetup=a.liosetup||{},a.liosetup.callback=a.liosetup.callback||[],a.liosetup.addEntityLoadedCallback=function(l){if("function"==typeof a.liosetup.callback){var o=[];o.push(a.liosetup.callback),a.liosetup.callback=o}a.lio&&a.lio.loaded?l(a.lio.data):a.liosetup.callback.push(l)}}(document,window);
        !function(e,n){var i=function(e){ga(function(){for(var e=ga.getAll(),i=[],a=0,t=e.length;a<t;a++){var o=e[a].get("trackingId"),g=e[a].get("name");o&&i.push({name:g,id:o})}for(a=0;a<n.lio.integrationsConfig.googleAdsIntegration.length;a++)for(var l=n.lio.integrationsConfig.googleAdsIntegration[a],d=0;d<i.length;d++)if(l.web_property===i[d].id){var g=i[d].name;n.ga(g+".require","displayfeatures"),n.ga(g+".set",l.segments_dimension,n.lio.segmentsString),n.ga(g+".set",l.user_id_dimension,n.lio._uid),ga("send","pageview")}})};n.liosetup&&"function"==typeof n.liosetup.addEntityLoadedCallback?n.liosetup.addEntityLoadedCallback(i):console.warn("unable to add Lytics callback, missing callback handler")}(document,window);
    </script>

    Here is a full example denoting the proper load order:

    <html>
        <head>
            <!-- Google Analytics Website Tracking -->
            <script>
              (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
              m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
              })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    
              ga('create', 'UA-35220005-2', 'auto');
              // ga('send', 'pageview'); <--- this is the line you will comment out or remove
            </script>
    
            <!-- Lytics Google Analytics Integration -->
            <script>
              !function(l,a){a.liosetup=a.liosetup||{},a.liosetup.callback=a.liosetup.callback||[],a.liosetup.addEntityLoadedCallback=function(l){if("function"==typeof a.liosetup.callback){var o=[];o.push(a.liosetup.callback),a.liosetup.callback=o}a.lio&&a.lio.loaded?l(a.lio.data):a.liosetup.callback.push(l)}}(document,window);
              !function(e,n){var i=function(e){ga(function(){for(var e=ga.getAll(),i=[],a=0,t=e.length;a<t;a++){var o=e[a].get("trackingId"),g=e[a].get("name");o&&i.push({name:g,id:o})}for(a=0;a<n.lio.integrationsConfig.googleAdsIntegration.length;a++)for(var l=n.lio.integrationsConfig.googleAdsIntegration[a],d=0;d<i.length;d++)if(l.web_property===i[d].id){var g=i[d].name;n.ga(g+".require","displayfeatures"),n.ga(g+".set",l.segments_dimension,n.lio.segmentsString),n.ga(g+".set",l.user_id_dimension,n.lio._uid),ga("send","pageview")}})};n.liosetup&&"function"==typeof n.liosetup.addEntityLoadedCallback?n.liosetup.addEntityLoadedCallback(i):console.warn("unable to add Lytics callback, missing callback handler")}(document,window);
            </script>
        </head>
        <body>
        </body>
    </html>

Lytics Event Override with Google Tag Manager

For those who are using Google Tag Manager, the steps are slightly different due to how load order and integrations are handled within that tool.

ga-tag-manager

Configure Google Analytics Tag

  1. Select Tags from the menu and click New to create a new tag container.
  2. Click Choose a tag type to begin setup... and select Custom HTML from the list.
    gtm-custom-tag-container
  3. Within this container you will place your Google Analytics tracking tag as instructed in step 2 of the Lytics Event Override section above. Essentially, you will copy and paste the Google Analytics tracking code and then remove the ga('send', 'pageview'); line so that Lytics does not send the pageview data before all data has been set with Google.
    GA Tag Example
  4. Under the Advanced Settings, adjust the Tag Firing Priority to be 10 for this tag. The higher the number, the sooner the script runs.
  5. Click on Triggering to configure when the tag is triggered. This is likely going to be All Pages but is dependent on execution details.
    Tag Firing Priority
  6. Name your tag and click Save.
    Save Tag

Configure Lytics Tag

  1. Select Tags from the menu and click New to create a new tag container.
  2. Click Choose a tag type to begin setup... and select Custom HTML from the list.
    Custom HTML Container
  3. In this tag you will paste the "Lytics Google Analytics Integration" from step 3 of the Lytics Event Override section above. Lytics GA Tag
  4. Under the Advanced Settings, adjust the Tag Firing Priority to be 9 for this tag. This ensures Lytics will run after Google Analytics has been initialized.
  5. Click on Triggering to configure when the tag is triggered. This is likely going to be All Pages but is dependent on execution details. This must match the targeting used in the Google Analytics container otherwise your GA tag will not fire.
    Tag Firing Priority
  6. Name your tag and click Save.
    Save Tag

At this point, everything should be configured. Publishing the latest version of your tag manager should result in audiences being passed into your Google Analytics account without sending additional, unnecessary events.

Verifying the Integration

A simple way to test that everything is working properly is to use the Google Analytics Debugger Chrome extension from Google. When activated, all of the data that is being passed to Google will also be output in your Google Developer Console. You will simply need to look for the Lytics audiences list in your event as seen here: