How to use Google Analytics custom segments in Chartio

You can use Google Analytics custom segments in SQL Mode.

First, navigate 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.

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 custom segment id via Google's Query Explorer, if you don't have it already

2. Build query in Interactive Mode in Chartio

3. Switch to SQL Mode, add "segments" header with segmentId, following the syntax in the example above

4. Add "ga:segment" under dimensions following the syntax in the example above.