Google Analytics Tips and Tricks

Data Sources
  1. Google Analytics data source connection
  2. Displaying Seconds as Time
  3. Using Google Analytics goal metrics
  4. Google Analytics sampling
  5. Querying Google Analytics custom segments
  6. Metrics and Dimensions to query in Google Analytics
  7. Google Analytics Custom Variables and Dimensions
  8. Google Analytics query limit
  9. Using custom segments in Google Analytics

Google Analytics data source connection

When adding a new Google Analytics data source to Chartio, you are prompted a Google login screen. After selecting the Google account and confirming the authorizations, if you return to Chartio but do not see the new data source listed, the issue may be that Google is not working with your ad blocker.

Please turn off any ad blocker on your browser and reconnect the Google Analytics source to Chartio.

Displaying Seconds as Time

In order to display seconds in a time format, for example, to be able to see the average time per page from Google Analytics, add an Add Column or [Edit Column **](/docs/data-pipeline/steps/#edit-column “Edit Column”)step in the Pipeline. Choose **Custom Formula and type in the following in the Formula field:

strftime('%H:%M:%f', "ga:avgTimeOnPage" ,'unixepoch')

Note: Replace “ga:avgTimeOnPage” with the name of your date time column.

Using Google Analytics goal metrics

Chartio supports querying all of the dimensions and metrics available through Google Analytics Core Reporting API. You can view the API documentation for more information.

If you’d like to use a goal conversion metric, you can—you’ll just need to enable it in your schema editor. Chartio hides some less commonly used columns by default to make your tables easier to navigate.

To enable hidden columns:

  1. From the top navigation, choose Settings > Data Sources.
  2. Select your Google Analytics data source and switch to the Schema tab.
  3. In the Schema Editor, find your column and check the Visible checkbox to the right of the column.

Your column will now be visible and can be used in any of your new or existing charts.

Goal conversions schema display

Google Analytics sampling

You may find inconstancies with Google Analytics data in Chartio. The main reason for this is the fact that Google Analytics samples their data (See Google documentation on data sampling for more information). Depending on what Google Analytics account you have, you may be limited to sampled data. Only the premium accounts support unsampled data.

Click here for Google Analytics account info.

However, the numbers should still be fairly close - sampling is meant to give you a close approximation.

It seems that the sample data is fairly accurate when it comes to visits and page views but it can vary in a wide range for revenue, transactions, and goal conversions. In one of the tests from the articles below, they found revenue could be off by 11% to 80%.

There’s a number of articles available by a quick Google search. Below are a few which could be helpful:

To get unsampled data for your team, you’d be required to have a Google Analytics Premium account and BigQuery.

We currently use Google’s Core Reporting API V4. You may be able to return more accurate results by using:

"samplingLevel": "LARGE"

More information can be found in Google’s Reporting API V4 documentation.

Additionally, you may be able to pull unsampled data using various other techniques, such as the following technique: Pull More than 10k rows Unsampled using Google Analytics Sheets Add-on.

Querying Google Analytics custom segments

You can use Google Analytics custom segments in SQL Mode.

First, go to the Google Analytics Query Explorer and log in to your Google Analytics account. Select your Property and View, and find your segment in the segment dropdown list.

Open the Google Analytics Query Explorer

Once you find your segment from the dropdown, you’ll see the segment id below its description. It will look something like gaid::-2.

You’ll need to use SQL Mode to include a custom segment, but we recommend building your chart in Interactive Mode first if you are not familiar with the Google Analytics querying language.

Once you have all of your dimensions and measures set up in Interactive Mode, switch to SQL Mode. Follow the format in the example below to insert your custom segment filter; add all of the bolded lines, replacing the segment id with your own.

"dateRanges":
- "endDate": "{TODAY}"
  "startDate": "2010-12-18"
"segments":
- "segmentId": "gaid::-2"
"dimensions":
- "name": "ga:date"
- "name": "ga:segment"
"includeEmptyRows": !!bool "true"
"metrics":
- "expression": "ga:sessions"
"pageSize": !!int "1000"
"post-process": "date"

In summary:

  1. Find the custom segment id via Google’s Query Explorer, if you don’t have it already.
  2. Build the query in Interactive Mode in Chartio.
  3. Switch to SQL Mode, add “segments” header with segment Id, following the syntax in the example above.
  4. Add ga:segment under dimensions following the syntax in the example above.

Metrics and Dimensions to query in Google Analytics

Not all Google Analytics metrics and dimensions can be queried together. Check if a dimension and a metric combination is valid from within Google’s documentation in the Dimensions and Metrics Explorer.

In this example, we want to see which metrics we can query with eventAction. Click the plus sign (+) to expand the Event Tracking table, which is where the eventAction dimension is located.

Click Event Tracking in the Core Reporting API documentation

Once the table is expanded, hover over ga:eventAction to reveal a checkbox, and check it. We’ll then want to see which metrics we can use in the eCommerce table, so we’ll expand the eCommerce table to compare the options.

Some of the metrics in the eCommerce table are greyed out as you can see below; this means we can’t query them with eventAction. You can query any metric that is not greyed out with eventAction.

Open eventAction under the Event Tracking tab

Google Analytics Custom Variables and Dimensions

By default, your Google Analytics data source schema in Chartio will only expose 5 custom variables and 20 custom dimensions. However, if you have an Analytics 360 (Premium) account, you can access up to 50 custom variables and 200 custom dimensions.

They can all be accessed from Chartio via SQL mode, but if you’d like to view all the columns in the schema please contact us at support@chartio.com to enable the additional custom variables and dimensions.

Google Analytics query limit

Google Analytics enforces a 10,000 row limit on all queries. This is a Google Analytics limit, not a Chartio limit.

Limit applied by Google Analytics

If you want to query past the limit applied to Google Analytics queries, you can use multiple Datasets. Using multiple Datasets in Chartio with the union join type, you can extract up to 100,000 rows.

See the Core ReportingAPI guide for more information on the Google Analytics limit.

Using custom segments in Google Analytics

You can use Google Analytics custom segments in SQL Mode.

To do this, open the Google Analytics Query Explorer and log in to your Google Analytics account. Select your segment from the dropdown list next to the segment input.

Once you select your segment from the dropdown, its ID will appear in the segment text input box. Copy the ID, including gaid:: at the beginning.

In your Google Analytics chart in Chartio, switch to SQL Mode at the top of the chart editor. Then, add your GA segment after your metrics, with &segment= added in front of it as done in the example below:

Codeblock in SQL Mode


Related Data Sources Help Articles

See more