If you already use Segment, it is worthwhile integrating with Google Analytics. This will allow you to utilize your existing Segment tracking code, which makes using Google Analytics simpler. For instance, there is no need to install Google Analytics code, and you’ll find it easier to configure advanced features like custom dimensions, custom metrics, and content groupings.
With Segment, you can send any data to Google Analytics that you’ve tracked through open-source libraries. Segment will send it in the right format, allowing you to act on the data immediately.
At this point, you will also start seeing real-time concurrent visitors on your Google Analytics dashboard.
If you have iOS or Android apps running Segment mobile libraries, these will start sending data to Google Analytics. If you have only just added the iOS or Android library to your app code, the process will begin straight away. Otherwise, new settings will take no more than one hour to propagate to existing users.
Lastly, Google Analytics will start collecting data from your site and mobile apps. Although this takes a few hours to complete, you will start noticing live events in your reports immediately.
After all this is complete, you can begin tracking what matters to you.
Calling page (More on a page call can be found here) sends a pageview to Google Analytics. The event name will correspond to the fullName of the page event — a combination of the category and name parameters. If you want to send pageviews from a server-side library, you need the URL property (More on properties in Segment can be found here) to avoid rejection from Google Analytics.
Calling screen in a mobile app is much like calling page. If you are sending a screen call server-side, you will again need to take steps to avoid rejection. This time, you need to pass in an application name using Segment’s context.app.name object. Skip this step if you’ve already set an application name in your iOS or Android project. Bear in mind that for iOS apps, Segment uses the name from the infoDictionary of your project.
Segment only sends the domain and path to Google Analytics. If you want to pass the entire URL with a query string to Google Analytics, you need to head to “Advanced Options” in the Segment destinations catalog. Check the box next to “Include the Query String in Pageviews.”
If you want Segment to pass anything from an identify call, you need to specify this. For instance, you can pass ID from identify calls after you enable User-ID in your Google Analytics property and create a User-ID view.
It is important to note that it is against Google’s terms of service to pass on personally identifiable information (PII). To avoid having your account suspended, you can send User-IDs but not emails, phone numbers, full names, nor any other PII.
After you have configured custom dimensions in Google Analytics, you can start mapping traits and properties. In your Segment dashboard, find the Google Analytics destinations catalog and choose “Advanced Options.” Here, you can find all the custom dimensions and declare mapping. You are able to map just one trait or property for each custom dimension at any time.
When you have finished mapping, you can check traits and properties in identify, track, and page calls. Segment will send dimensions that are defined in your mapping to Google Analytics. Traits in identify calls are sent to Google Analytics once the next track or page call is fired from the browser.
Identify Calls from Server-Side Libraries
You can send .identify() calls to Google Analytics from server-side libraries. You can also send them from Segment Cloud apps with enriched user traits. The data must go through custom dimensions and metrics. Segment will check traits and settings and send them with an explicit event.
You have the option to specify a name for the event action; otherwise, it will receive the default of “User Enriched.” You can also specify the trait you want to set as the value for the event category. Without an event category, it receives the value “All.”
You can create events with the nonInteraction flag. You simply need to pass to Segment the event property labeled as nonInteraction with the value of 1. You can also set this for all events by heading to “Advanced Options.”
These are just a few ways to use Segment with Google Analytics. Once you have integrated the two, discover the many other ways that Segment simplifies working with Google Analytics.