# Google Analytics Integration

**Caveat**: each of the following integration directions was based on the UI when it was written. The UIs may change by the time you read this, so *UI updates are beyond the scope of these articles*. Please go to the integration target sites for their latest information on integration directions.

Google Analytics integration provides insight into the correlation between actual traffic metrics and ongoing monitoring checks.

## Intro <a href="#googleanalyticsintegration-intro" id="googleanalyticsintegration-intro"></a>

Google Analytics (GA) is both free and easy to set up and use for novices and professionals alike, making it the go-to web analytics tool.

The Synthetic Monitoring integration with Google Analytics integration provides additional features:

* A dashboard with the most popular metrics from Google Analytics such as Visits, Page Views, and Average Visit Duration, all plotted on easy-to-read charts.
* A Google Analytics Real-Time Check.
* The ability to compare metrics (Visits and Page Views) from Google Analytics with performance metrics on the Check Results page.

### Sample views: <a href="#googleanalyticsintegration-sampleviews" id="googleanalyticsintegration-sampleviews"></a>

#### Integration Dashboard <a href="#googleanalyticsintegration-integrationdashboard" id="googleanalyticsintegration-integrationdashboard"></a>

#### Integration Check <a href="#googleanalyticsintegration-integrationcheck" id="googleanalyticsintegration-integrationcheck"></a>

## Setting up Google Analytics Real-Time Integration Check <a href="#googleanalyticsintegration-settingupgoogleanalyticsreal-timeintegrationcheck" id="googleanalyticsintegration-settingupgoogleanalyticsreal-timeintegrationcheck"></a>

You’ll already have set up a Google Analytics account need to set the integration up.

| **Step**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | **Screenshot**                                                                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Start from the **New Integration+** → **Google Analytics Real-Time** ASM Menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |                                                                                                                                                                                                                                                                                                                      |
| <h4 id="googleanalyticsintegration-step1-addthegareal-timecheck">Step 1: Add the GA Real-Time Check</h4><ul><li>Add a <strong>Name</strong> and <strong>Description</strong></li><li>Add <strong>Tags</strong> for easier sorting, categorization, and grouping</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                      |
| <h4 id="googleanalyticsintegration-step2-commandandlocation">Step 2: Command and Location</h4><p>Enter the <strong>View ID</strong>: This is your specific Google Analytics Account ID. The format is <code>ga:{View ID}</code> example <code>ga:12345678</code></p><p>Select the <strong>Metric:</strong></p><ul><li><strong>Active Users</strong>: How many visitors were <strong>active</strong> on your site over a given period of time. The <strong>active users</strong> report in Google Analytics helps you understand your website's (or mobile app’s) retention rate. It reports on how often visitors come back to your website over a certain time period.</li><li><strong>Page Views</strong>: Page view measurement allows you to measure the number of views you had for a particular page on your <em><strong>website</strong></em>. Pages often correspond to an entire HTML document, but they can also represent dynamically loaded content; this is known as "virtual pageviews."</li><li><strong>Screen Views</strong>: Screens in Google Analytics represent content users are viewing within an <em><strong>app</strong></em>. The equivalent concept for a website is <a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/pages">pages</a>. Measuring screen views allows you to see which content is being viewed most by your users and how are they are navigating between different pieces of content.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                                                                                                                                                                                                                                                                                                                      |
| <h4 id="googleanalyticsintegration-step3-setinterval-thresholds-and-monitorgroups">Step 3: Set Interval, Thresholds & Monitor Groups</h4><ul><li><strong>Polling Interval</strong></li></ul><p>For all the thresholds, there are these types</p><ul><li><strong>Baseline</strong> <strong>Constant</strong>: A constant, fixed, Threshold.</li><li><p><strong>Average</strong>: A dynamically calculated Threshold based on the <em>Average</em> of the check’s returned value. ASM will look at the specified period of time (2-1440 Hours. 1440 Hours = 60 Days) and calculate a Threshold value based on the percentage of the average returned value plus the offset (of the Returned Value) value specified by the user.</p><p><em>The example shown</em>: 150% of the average returned value for the last two hours plus 50 offset.</p></li><li><p><strong>Median</strong>: A dynamically calculated Threshold based on the <em>Median</em> of the check’s returned values. ASM will look at the specified period of time (2-1440 Hours. 1440 Hours = 60 Days) and calculate a Threshold value based on the percentage of the median returned value plus the offset (of the Returned Value) value specified by the user.</p><p><em>Example shown</em>: 120% of the median returned value for the last two hours plus 0 offset.</p></li><li><p><strong>Standard</strong> <strong>Deviation</strong>: A dynamically calculated Threshold based on the <a href="https://en.wikipedia.org/wiki/Standard_deviation">Standard Deviation</a> of check’s returned values. ASM will look at the specified period of time (2-1440 Hours. 1440 Hours = 60 Days) and calculate a Threshold based on Standard Deviations (1, 1.5, 2, 2.5, 3, 5, or 10) plus the average returned value for the period of time plus the offset (of the Returned Value) value specified by the user.</p><p><em>Example shown</em>: Two Standard Deviations plus the average value for the last two hours plus 10 offset.</p></li><li><strong>High Warning Threshold</strong>: If the returned value from the check passes over the High Warning Threshold, it will trigger a Severity change of the check Warning (<strong>Yellow</strong>).</li><li><strong>High Error Threshold</strong>: If the returned value from the check passes over the High Error Threshold, it will trigger a Severity change of the check Error (<strong>Orange</strong>).</li><li><strong>Low Warning</strong> <strong>Threshold</strong>: If the returned value from the check drops below the Low Warning Threshold, it will trigger a Severity change of the check Warning (<strong>Yellow</strong>).</li><li><strong>Low Error Threshold</strong>: If the returned value from the check drops below the Low Error Threshold, it will trigger a Severity change of the check Error (<strong>Orange</strong>).</li><li><strong>Monitor Group(s)</strong>: Select what Groups these checks will be reported under. If you have many Monitor Groups, enter a few letters of the group name(s) to filter down the list.</li></ul> | <p></p><p><strong>Average Example:</strong></p><p></p><p><strong>Median Example:</strong></p><p></p><p><strong>Standard Deviation Example:</strong></p><p></p><p><strong>Monitor Group(s)</strong></p><p></p><p>Click <em><strong>Next</strong></em> when you have set the Interval, Thresholds & Monitor Groups</p> |
| <h4 id="googleanalyticsintegration-summaryandconfirmationpage">Summary and Confirmation Page</h4><p>When satisfied, click <em><strong>Create</strong></em> to create the check.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                      |

## Google Analytics Data Policy <a href="#googleanalyticsintegration-googleanalyticsdatapolicy" id="googleanalyticsintegration-googleanalyticsdatapolicy"></a>

There are two use-cases for Google Analytics (1) Display of the ASM Dashboard, (2) Creating a Google Analytics Real-Time Check.

### GA and the ASM Dashboard <a href="#googleanalyticsintegration-gaandtheasmdashboard" id="googleanalyticsintegration-gaandtheasmdashboard"></a>

For the Apica [ASM Dashboard](https://wpm.apicasystem.com/Analytics/Dashboard), we gather these Google Analytics metrics for display:

* ga:visits
* ga:visitors
* ga:pageviews
* ga:pageviewsPerVisit
* ga:avgPageLoadTime
* ga:newVisits,
* ga:percentNewVisits,
* ga:avgSessionDuration,
* ga:visitBounceRate,

Apica does not store them; it only shows the values for this page.

### GA and the ASM Google Analytics Real-time Check <a href="#googleanalyticsintegration-gaandtheasmgoogleanalyticsreal-timecheck" id="googleanalyticsintegration-gaandtheasmgoogleanalyticsreal-timecheck"></a>

When Apica creates a Google Analytics Real-Time check, we gather these metrics:

* [rt:activeUsers](https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/user)
* [rt:pageviews](https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/pagetracking?hl=en)
* [rt:screenViews](https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/apptracking?hl=en)

Apica stores these metric values as check results in our SQL/Mongo database.

* We store these values for up to 1 year for raw data
* Aggregated data (e.g., median, average, min, max by hours, weeks, months) is stored as long as the user has an active subscription in Apica Synthetic Monitoring.
