How to use Google Analytics API without any coding
In this article, I will show you how to use the Google Analytics API without doing any coding.
Introduction to APIs
An application programming interface (or API) is the interface between two program modules.
This interface is made up of sets of routines, protocols, and tools.
Through API you can:
- Create new software applications.
- Integrate your application with a third party application.
- Enhance the functionality of an existing application.
Every program has to depend upon another program in order to carry out some of its functions.
For example, your web browser has to depend upon an operating system in order to work. Your operating system has to depend upon system applications in order to work.
In fact, an API itself has to depend upon an ABI (application binary interface) in order to work. Without APIs, you need to create all of the functionality from scratch and that too at the binary level (01010101).
There are many different types of APIs.
There are APIs used by operating systems, APIs used by non-system applications, APIs used by websites (Web APIs) etc.
A web API is an API that defines the interface between a web browser and a web server.
If you want to use the functionality provided by Facebook in your program/application, then you need to write a program that can interact with Facebook API by making a request called API call.
You need to go through the developer documentation provided by Facebook in order to understand how you can make your program interact with Facebook API.
Similarly, if you want to use the functionality provided by Google Analytics, then you may need to write a program that can interact with Google Analytics API.
Introduction to Google Analytics APIs
Google Analytics provides two types of APIs:
- Management API
- Core Reporting API
Through management API you can access information related to your Google Analytics accounts (like account ID), web properties and views. But you can’t access actual report data through Management API.
To access the actual report data (like sessions, pageviews, bounce rate, etc) you need to use the Core Reporting API.
Following are some of the advantages of using Google Analytics APIs:
- Query and manage dozens of analytics properties/websites at once.
- Merge Google Analytics data with other data sources.
- Retrieve information in almost any way you want.
- Schedule Google Analytics exports to Excel, Big Query, etc.
- Automate dashboards and reports creation.
- Reduce/eliminate data sampling through query partitioning.
- Automate the import of cost data into Google Analytics
- Simplify data extraction, integration, and visualization.
- and the list goes on …….
You indirectly access both management API and core reporting API without writing any code through the online software provided by Google Analytics. Every time you access one of the reports of Google Analytics, you are indirectly using Google Analytics APIs.
However, if you want to access Google Analytics APIs directly, for example, access Google Analytics data directly into your spreadsheet, you need to write a code that can make a request to Google Analytics API.
This is where many people struggle.
Writing code that can make API calls is not easy. So in order to facilitate this process, there are a number of third-party tools out there (like Analytics Canvas) that make it possible to directly interact with Google Analytics APIs without writing any program.
In this article, I will show you how to access Google Analytics APIs without doing any coding via the Google Analytics Spreadsheet add-on. In order to use this add on you need to first get familiar with:
#1 Google Analytics Account Explorer
#2 Google Analytics Dimensions and Metrics Explorer
#3 Core Reporting API Dimensions and Metrics
#4 Core Reporting API Filters
#5 Google Analytics Query Explorer
Get weekly practical tips on GA4 and/or BigQuery to accurately track and read your analytics data.
Google Analytics Account Explorer
Through the Google Analytics Account Explorer tool you can get the following information:
#1 You can determine the list of all the Google Analytics Accounts, Properties, and Views you have got access to.
#2 You can determine your account ID, web property ID, view ID, and table ID. This information comes handy when later you access Google Analytics (GA) via APIs:
In order to use this tool, follow the steps below:
Step-1: Navigate to Google Analytics account explorer: https://ga-dev-tools.appspot.com/account-explorer/
Step-2: Connect this tool to your Google Analytics Account by clicking on the ‘Click here to authorize’ link:
If you are not already logged in your Google account then Google will ask you to log in first. However, if you are already logged in then you will be asked to allow ga-dev-tools.appspot.com to view your Google Analytics data:
Click on the ‘Allow‘ button.
Note: You need this authorization in order to use Account explorer and Query explorer tools.
Step-3: Select your Google Analytics account, web property and view from the drop-down menus:
You can now see the various IDs (account IDs, web property IDs, view IDs, and table IDs) related to your GA account.
Google Analytics Dimensions and Metrics Explorer
Google Analytics Dimensions and Metrics Explorer tool list and explain all of the dimensions and metrics available via Core reporting API.
It also tells you which dimensions and metrics can be queried/used together. Not all dimensions and metrics can be queried together.
In order to use this tool, follow the steps below:
Step-1: Navigate to Google Analytics Dimensions and Metrics explorer: https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/
You can also access this tool by clicking on the ‘Dimensions and Metrics explorer‘ link from the left hand side navigation menu while using the Google Analytics account explorer tool:
Note: ‘Account explorer‘, ‘Query Explorer‘, ‘Campaign URL builder‘, ‘Hit Builder‘ and ‘Google Analytics spreadsheet Add-on‘ tools are also accessible via this navigation menu.
You will now see the landing page like the one below:
This landing page list and explain all the dimensions and metrics available via Core Reporting API.
The dimensions and metrics are listed under groups:
The screenshot above shows the following groups:
- User
- Session
- Traffic Sources
- Adwords
- Goal Conversions
- Platform or Device
Step-2: Click on the plus (+) button next to a group name to see the list of all the dimensions and metrics which are available for that group:
From the screenshot above we can conclude the following two things:
#1 Following dimensions are available for the ‘User’ group:
- User Type (ga:userType)
- Count of Sessions (ga:sessionCount)
- Days Since Last Session (ga:daysSinceLastSession)
- User Defined Value (ga:userDefinedValue)
- User Bucket (ga:userBucket)
#2 Following metrics are available for the ‘User’ group:
- Users (ga:users)
- New Users (ga:newUsers)
- % New Sessions (ga:percentNewSessions)
- 1 Day Active Users (ga:1dayUsers)
- 7 Day Active Users (ga:7dayUsers)
- 14 Day Active Users (ga:14dayUsers)
- 28 Day Active Users (ga:28dayUsers)
- 30 Day Active Users (ga:30dayUsers)
- Number of Sessions per User (ga:sessionsPerUser)
Step-3: Click on the checkbox next to a dimension, to see which metric(s) can be used/queried together with the dimension. For example in the screenshot below, I selected the ‘User Type’ dimension:
Now all the metrics which are greyed out can not be used together with the ‘user type’ dimension.
So the metrics which can be used/queried together with the ‘user type’ dimension are:
- Users (ga:users)
- New Users (ga:newUsers)
- % New Sessions (ga:percentNewSessions)
- Number of Sessions per User (ga:sessionsPerUser)
Step-4: To learn more about a particular dimension, just click on its name:
Step-5: To learn more about a particular metric, just click on its name:
That’s how you can use dimensions and metrics explorer tool.
Now at this point, you may be wondering, what is the point of knowing all this. All of the knowledge will later help you when you use the Google Analytics Spreadsheet Add-on.
Core Reporting API Dimensions and Metrics
When we access Google Analytics directly via API, we use the API name of a dimension/metric/segment instead of the web view name (also known as UI name):
Web view names (or User Interface names) are the names of dimensions, metrics and custom segments you see in Google Analytics reports:
Following are the corresponding API names:
It is important that you understand the difference between a web view name and API name. Otherwise, you can’t access GA via API through Google Analytics Spreadsheet Add-on.
Core Reporting API Filters
In order to get meaningful data via Core reporting API, you must know, how to use and apply API filters.
Following is the syntax of the core reporting API filter:
name operator expression
Here,
name – is the API name of a Google Analytics dimension or metric to which you want to apply a filter. For example: ga:region, ga:country, ga:sessions etc.
operator – it can be any dimension or metric filter operator listed below:
Note: These operators must be URL encoded before they can be included in a query string. For example, the URL encoded form of == operator would be %3D%3D.
However, if you are using ‘Query explorer’ or ‘GA spreadsheet add-on’ that you don’t need to URL encode the operators.
expression – it is a regular expression
For example:
ga:country==United States
This filter instructs the Google Analytics API to report only that hit data (pageview, screenviews, events, items, etc) which is from the country called ‘United States’.
Another example:
ga:region=~^c
This filter instructs the Google Analytics API to report the hit data of only those regions whose name starts with the letter ‘C’.
Here =~ is one of the dimension filter operator and ^ is the caret sign which has got special meaning in regex.
API filters become most useful when they are combined with other filters.
You can use AND and OR operators to combine two or more filters.
The AND operator is denoted by a semicolon (;) whereas OR operator is denoted by comma (,)
For example:
ga:country==United States;ga:region=~^c
This filter instructs the API to report only that hit data which is from US regions and whose names start with the letter ‘C’.
Another example,
ga:country==United States,ga:country==United Kingdom
This filter instructs the API to report only that hit data which is either from the US or from the UK.
Google Analytics Query Explorer
In order to access GA data via core reporting API, you need to build and execute queries. Through Google Analytics query explorer you can do that.
Just to show you how this tool can be used, I will reproduce the data from the following Google Analytics report via API:
There are few things which you need to note about this report:
#1 This report list only the regions in US.
#2 This report list only those regions whose name starts with the letter ‘C’. This was achieved by using an advanced filter on the reporting interface.
#3 A default custom segment called ‘organic search’ is applied to this report.
#4 This report includes one dimension called ‘Region‘ and 4 metrics: New users, % New Sessions, Sessions and Goal 4 value.
#5 This report sorts the ‘New Users’ metric in descending order.
Follow the steps below to use the Google Analytics Query Explorer tool:
Step-1: Navigate to Google Analytics Query Explorer tool: https://ga-dev-tools.appspot.com/query-explorer/
Step-2: Select the Google Analytics account, property and view whose data you want to access via the API from the drop-down menus:
Step-3: Select ‘Start date’ and ‘end date’. This is the date range for which you want to see the data:
Step-4: Select the metrics you want to include in your report from the drop-down menu:
Here I have selected the four metrics whose API names are: ga:newUsers, ga:percentNewSessions, ga:sessions and ga:goal4value in order to reproduce the data from the GA report above.
Step-5: Select your dimension (in this case ga:region) from the drop-down menu:
Step-6: Select the sorting order and the sorting direction from the drop-down menu:
I selected new users descending (-ga:newUsers) because the GA report above, sort the ‘New Users’ metric in descending order.
Step-7: Enter the filter expression in the ‘filters’ box:
I entered the following filter expression: ga:country==United States;ga:region=~^c because the GA report (whose data I want to reproduce) lists only those regions in US whose name starts with the letter ‘C’.
Step-8: Select the ‘organic traffic’ segment from the drop-down menu:
Step-9: Set the sampling level (to adjust data sampling) to DEFAULT, FASTER or HIGHER_PRECISION:
I set the sampling level to DEFAULT by leaving the ‘sampling level’ parameter field blank.
Step-10: Set the ‘start index’ parameter:
This parameter is used to specify the row number i.e. the row from where you want to start retrieving the GA data.
For example, if you have got say 1000 rows in your report and you want to retrieve data from the 900th row then set the ‘start index’ parameter to 900.
The default value of this parameter is 1 which can also be specified by leaving the ‘start index’ parameter field empty.
Since I want to retrieve results from the beginning, I left the ‘start index’ parameter field empty.
Step-11: Set the ‘max-results’ parameter:
This parameter denotes the maximum number of rows you want to include in your report.
Since I don’t want to include more than 10 rows in my report, I set the max-results parameter to 10.
Step-12: Click on the ‘Run Query’ button. You will then see a report from the query explorer tool like the one below:
Note the data from this report matches with our Google Analytics report:
This proves that our query was correct.
Google Analytics Spreadsheet Add-on
Once you understand how to use the query explorer, you are in a good position to use the Google Analytics Spreadsheet add-on.
Through this add-on, you can access Google Analytics data directly via core reporting API into a Google Spreadsheet.
Just to show you how this tool can be used, I will reproduce the data from the following Google Analytics report via the Google Analytics spreadsheet add-on:
Follow the steps below to use this tool:
Step-1: Install Google Analytics Spreadsheet add-on from here: https://chrome.google.com/webstore/detail/google-analytics/fefimfimnhjjkomigakinmjileehfopp
Step-2: Open a new Google Spreadsheet and then go to the Add-ons menu > Google Analytics > ‘Create New Report‘:
Step-3: Configure the new report like the one below:
I have selected the metrics and dimensions according to the GA report I want to reproduce.
Step-4: Click on the ‘create report’ button. You will then see a report like the one below:
If you look closely at this report, you can see that the following fields are empty:
- Start date
- End date
- Sort
- Filters
- Segment
- Max Results
You can get all of this data from Query Explorer.
Once you have supplied all of the required data, your Google spreadsheet may look like the one below:
Note: Here I deleted the value of the ‘Last N Days‘ field and changed the metric ga:goalXXValue to ga:goal4Value.
Step-5: Again navigate to Add-ons menu > Google Analytics > ‘Run Reports‘:
If there is no error in any of your query parameters, you will get a ‘completed successfully’ report status like the one below:
If there is an error in one of your query parameters, you will get a ‘report failed’ report status like the one below:
Note: You are less likely to get errors if you build your queries through query explorer (instead of manually) before you start using GA Spreadsheet add on.
Step-6: Click on the ‘ok’ button of the ‘Report Status’ dialog box:
If there is no error in your query parameters then you will see a new tab added to your Google spreadsheet.
This tab contains your new report:
Note the data from this report matches with the Google Analytics report:
This is proof that you correctly downloaded data from Google Analytics into Google Sheets via the Google Analytics Spreadsheet add-on.
Related Article: How to use Google Analytics Real-Time Reporting API
Other Web Analytics Tools
- How to use Keyword Hero to reveal Not Provided keywords in Google Analytics
- Regular Expressions Guide for Google Analytics and Google Tag Manager
- Beginners Guide to Coding for SEO & Web Analytics
- Google Analytics Usage Trends Tool
- Why you may no longer need Google Tag Manager
- Optimize Smart Web Analytics Tool Box
- Best Google Analytics Shortcuts: Tricks, Tools & APIs to save Time
- Excel for SEO & Analytics – Powerful Cheat Sheet
Frequently Asked Questions About How to use Google Analytics API Without Any Coding
What is an API?
An application programming interface (or API) is the interface between two program modules. This interface is made up of sets of routines, protocols, and tools.
Through an API you can:
– Create new software applications.
– Integrate your application with a third party application.
– Enhance the functionality of an existing application.
What APIs does Google Analytics provide?
Google Analytics provides two types of APIs:
– Management API
– Core Reporting API
Through management API you can access information related to your Google Analytics accounts (like account ID), web properties and views. To access the actual report data (like sessions, pageviews, bounce rate, etc) you need to use the Core Reporting API.
Do I have to write code to access the Google Analytics API?
Not necessarily! Writing code that can make API calls is not easy. So in order to facilitate this process, there are a number of third-party tools out there (like Analytics Canvas) that make it possible to directly interact with Google Analytics APIs without writing any program. In this article, I will show you how to access Google Analytics APIs without doing any coding via the Google Analytics Spreadsheet add-on
What is the Google Analytics Dimensions and Metrics Explorer?
The Google Analytics Dimensions and Metrics Explorer tool lists and explains all of the dimensions and metrics available via the Core reporting API.
It also tells you which dimensions and metrics can be queried/used together. Not all dimensions and metrics can be queried together.
https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/
In this article, I will show you how to use the Google Analytics API without doing any coding.
Introduction to APIs
An application programming interface (or API) is the interface between two program modules.
This interface is made up of sets of routines, protocols, and tools.
Through API you can:
- Create new software applications.
- Integrate your application with a third party application.
- Enhance the functionality of an existing application.
Every program has to depend upon another program in order to carry out some of its functions.
For example, your web browser has to depend upon an operating system in order to work. Your operating system has to depend upon system applications in order to work.
In fact, an API itself has to depend upon an ABI (application binary interface) in order to work. Without APIs, you need to create all of the functionality from scratch and that too at the binary level (01010101).
There are many different types of APIs.
There are APIs used by operating systems, APIs used by non-system applications, APIs used by websites (Web APIs) etc.
A web API is an API that defines the interface between a web browser and a web server.
If you want to use the functionality provided by Facebook in your program/application, then you need to write a program that can interact with Facebook API by making a request called API call.
You need to go through the developer documentation provided by Facebook in order to understand how you can make your program interact with Facebook API.
Similarly, if you want to use the functionality provided by Google Analytics, then you may need to write a program that can interact with Google Analytics API.
Introduction to Google Analytics APIs
Google Analytics provides two types of APIs:
- Management API
- Core Reporting API
Through management API you can access information related to your Google Analytics accounts (like account ID), web properties and views. But you can’t access actual report data through Management API.
To access the actual report data (like sessions, pageviews, bounce rate, etc) you need to use the Core Reporting API.
Following are some of the advantages of using Google Analytics APIs:
- Query and manage dozens of analytics properties/websites at once.
- Merge Google Analytics data with other data sources.
- Retrieve information in almost any way you want.
- Schedule Google Analytics exports to Excel, Big Query, etc.
- Automate dashboards and reports creation.
- Reduce/eliminate data sampling through query partitioning.
- Automate the import of cost data into Google Analytics
- Simplify data extraction, integration, and visualization.
- and the list goes on …….
You indirectly access both management API and core reporting API without writing any code through the online software provided by Google Analytics. Every time you access one of the reports of Google Analytics, you are indirectly using Google Analytics APIs.
However, if you want to access Google Analytics APIs directly, for example, access Google Analytics data directly into your spreadsheet, you need to write a code that can make a request to Google Analytics API.
This is where many people struggle.
Writing code that can make API calls is not easy. So in order to facilitate this process, there are a number of third-party tools out there (like Analytics Canvas) that make it possible to directly interact with Google Analytics APIs without writing any program.
In this article, I will show you how to access Google Analytics APIs without doing any coding via the Google Analytics Spreadsheet add-on. In order to use this add on you need to first get familiar with:
#1 Google Analytics Account Explorer
#2 Google Analytics Dimensions and Metrics Explorer
#3 Core Reporting API Dimensions and Metrics
#4 Core Reporting API Filters
#5 Google Analytics Query Explorer
Google Analytics Account Explorer
Through the Google Analytics Account Explorer tool you can get the following information:
#1 You can determine the list of all the Google Analytics Accounts, Properties, and Views you have got access to.
#2 You can determine your account ID, web property ID, view ID, and table ID. This information comes handy when later you access Google Analytics (GA) via APIs:
In order to use this tool, follow the steps below:
Step-1: Navigate to Google Analytics account explorer: https://ga-dev-tools.appspot.com/account-explorer/
Step-2: Connect this tool to your Google Analytics Account by clicking on the ‘Click here to authorize’ link:
If you are not already logged in your Google account then Google will ask you to log in first. However, if you are already logged in then you will be asked to allow ga-dev-tools.appspot.com to view your Google Analytics data:
Click on the ‘Allow‘ button.
Note: You need this authorization in order to use Account explorer and Query explorer tools.
Step-3: Select your Google Analytics account, web property and view from the drop-down menus:
You can now see the various IDs (account IDs, web property IDs, view IDs, and table IDs) related to your GA account.
Google Analytics Dimensions and Metrics Explorer
Google Analytics Dimensions and Metrics Explorer tool list and explain all of the dimensions and metrics available via Core reporting API.
It also tells you which dimensions and metrics can be queried/used together. Not all dimensions and metrics can be queried together.
In order to use this tool, follow the steps below:
Step-1: Navigate to Google Analytics Dimensions and Metrics explorer: https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/
You can also access this tool by clicking on the ‘Dimensions and Metrics explorer‘ link from the left hand side navigation menu while using the Google Analytics account explorer tool:
Note: ‘Account explorer‘, ‘Query Explorer‘, ‘Campaign URL builder‘, ‘Hit Builder‘ and ‘Google Analytics spreadsheet Add-on‘ tools are also accessible via this navigation menu.
You will now see the landing page like the one below:
This landing page list and explain all the dimensions and metrics available via Core Reporting API.
The dimensions and metrics are listed under groups:
The screenshot above shows the following groups:
- User
- Session
- Traffic Sources
- Adwords
- Goal Conversions
- Platform or Device
Step-2: Click on the plus (+) button next to a group name to see the list of all the dimensions and metrics which are available for that group:
From the screenshot above we can conclude the following two things:
#1 Following dimensions are available for the ‘User’ group:
- User Type (ga:userType)
- Count of Sessions (ga:sessionCount)
- Days Since Last Session (ga:daysSinceLastSession)
- User Defined Value (ga:userDefinedValue)
- User Bucket (ga:userBucket)
#2 Following metrics are available for the ‘User’ group:
- Users (ga:users)
- New Users (ga:newUsers)
- % New Sessions (ga:percentNewSessions)
- 1 Day Active Users (ga:1dayUsers)
- 7 Day Active Users (ga:7dayUsers)
- 14 Day Active Users (ga:14dayUsers)
- 28 Day Active Users (ga:28dayUsers)
- 30 Day Active Users (ga:30dayUsers)
- Number of Sessions per User (ga:sessionsPerUser)
Step-3: Click on the checkbox next to a dimension, to see which metric(s) can be used/queried together with the dimension. For example in the screenshot below, I selected the ‘User Type’ dimension:
Now all the metrics which are greyed out can not be used together with the ‘user type’ dimension.
So the metrics which can be used/queried together with the ‘user type’ dimension are:
- Users (ga:users)
- New Users (ga:newUsers)
- % New Sessions (ga:percentNewSessions)
- Number of Sessions per User (ga:sessionsPerUser)
Step-4: To learn more about a particular dimension, just click on its name:
Step-5: To learn more about a particular metric, just click on its name:
That’s how you can use dimensions and metrics explorer tool.
Now at this point, you may be wondering, what is the point of knowing all this. All of the knowledge will later help you when you use the Google Analytics Spreadsheet Add-on.
Core Reporting API Dimensions and Metrics
When we access Google Analytics directly via API, we use the API name of a dimension/metric/segment instead of the web view name (also known as UI name):
Web view names (or User Interface names) are the names of dimensions, metrics and custom segments you see in Google Analytics reports:
Following are the corresponding API names:
It is important that you understand the difference between a web view name and API name. Otherwise, you can’t access GA via API through Google Analytics Spreadsheet Add-on.
Core Reporting API Filters
In order to get meaningful data via Core reporting API, you must know, how to use and apply API filters.
Following is the syntax of the core reporting API filter:
name operator expression
Here,
name – is the API name of a Google Analytics dimension or metric to which you want to apply a filter. For example: ga:region, ga:country, ga:sessions etc.
operator – it can be any dimension or metric filter operator listed below:
Note: These operators must be URL encoded before they can be included in a query string. For example, the URL encoded form of == operator would be %3D%3D.
However, if you are using ‘Query explorer’ or ‘GA spreadsheet add-on’ that you don’t need to URL encode the operators.
expression – it is a regular expression
For example:
ga:country==United States
This filter instructs the Google Analytics API to report only that hit data (pageview, screenviews, events, items, etc) which is from the country called ‘United States’.
Another example:
ga:region=~^c
This filter instructs the Google Analytics API to report the hit data of only those regions whose name starts with the letter ‘C’.
Here =~ is one of the dimension filter operator and ^ is the caret sign which has got special meaning in regex.
API filters become most useful when they are combined with other filters.
You can use AND and OR operators to combine two or more filters.
The AND operator is denoted by a semicolon (;) whereas OR operator is denoted by comma (,)
For example:
ga:country==United States;ga:region=~^c
This filter instructs the API to report only that hit data which is from US regions and whose names start with the letter ‘C’.
Another example,
ga:country==United States,ga:country==United Kingdom
This filter instructs the API to report only that hit data which is either from the US or from the UK.
Google Analytics Query Explorer
In order to access GA data via core reporting API, you need to build and execute queries. Through Google Analytics query explorer you can do that.
Just to show you how this tool can be used, I will reproduce the data from the following Google Analytics report via API:
There are few things which you need to note about this report:
#1 This report list only the regions in US.
#2 This report list only those regions whose name starts with the letter ‘C’. This was achieved by using an advanced filter on the reporting interface.
#3 A default custom segment called ‘organic search’ is applied to this report.
#4 This report includes one dimension called ‘Region‘ and 4 metrics: New users, % New Sessions, Sessions and Goal 4 value.
#5 This report sorts the ‘New Users’ metric in descending order.
Follow the steps below to use the Google Analytics Query Explorer tool:
Step-1: Navigate to Google Analytics Query Explorer tool: https://ga-dev-tools.appspot.com/query-explorer/
Step-2: Select the Google Analytics account, property and view whose data you want to access via the API from the drop-down menus:
Step-3: Select ‘Start date’ and ‘end date’. This is the date range for which you want to see the data:
Step-4: Select the metrics you want to include in your report from the drop-down menu:
Here I have selected the four metrics whose API names are: ga:newUsers, ga:percentNewSessions, ga:sessions and ga:goal4value in order to reproduce the data from the GA report above.
Step-5: Select your dimension (in this case ga:region) from the drop-down menu:
Step-6: Select the sorting order and the sorting direction from the drop-down menu:
I selected new users descending (-ga:newUsers) because the GA report above, sort the ‘New Users’ metric in descending order.
Step-7: Enter the filter expression in the ‘filters’ box:
I entered the following filter expression: ga:country==United States;ga:region=~^c because the GA report (whose data I want to reproduce) lists only those regions in US whose name starts with the letter ‘C’.
Step-8: Select the ‘organic traffic’ segment from the drop-down menu:
Step-9: Set the sampling level (to adjust data sampling) to DEFAULT, FASTER or HIGHER_PRECISION:
I set the sampling level to DEFAULT by leaving the ‘sampling level’ parameter field blank.
Step-10: Set the ‘start index’ parameter:
This parameter is used to specify the row number i.e. the row from where you want to start retrieving the GA data.
For example, if you have got say 1000 rows in your report and you want to retrieve data from the 900th row then set the ‘start index’ parameter to 900.
The default value of this parameter is 1 which can also be specified by leaving the ‘start index’ parameter field empty.
Since I want to retrieve results from the beginning, I left the ‘start index’ parameter field empty.
Step-11: Set the ‘max-results’ parameter:
This parameter denotes the maximum number of rows you want to include in your report.
Since I don’t want to include more than 10 rows in my report, I set the max-results parameter to 10.
Step-12: Click on the ‘Run Query’ button. You will then see a report from the query explorer tool like the one below:
Note the data from this report matches with our Google Analytics report:
This proves that our query was correct.
Google Analytics Spreadsheet Add-on
Once you understand how to use the query explorer, you are in a good position to use the Google Analytics Spreadsheet add-on.
Through this add-on, you can access Google Analytics data directly via core reporting API into a Google Spreadsheet.
Just to show you how this tool can be used, I will reproduce the data from the following Google Analytics report via the Google Analytics spreadsheet add-on:
Follow the steps below to use this tool:
Step-1: Install Google Analytics Spreadsheet add-on from here: https://chrome.google.com/webstore/detail/google-analytics/fefimfimnhjjkomigakinmjileehfopp
Step-2: Open a new Google Spreadsheet and then go to the Add-ons menu > Google Analytics > ‘Create New Report‘:
Step-3: Configure the new report like the one below:
I have selected the metrics and dimensions according to the GA report I want to reproduce.
Step-4: Click on the ‘create report’ button. You will then see a report like the one below:
If you look closely at this report, you can see that the following fields are empty:
- Start date
- End date
- Sort
- Filters
- Segment
- Max Results
You can get all of this data from Query Explorer.
Once you have supplied all of the required data, your Google spreadsheet may look like the one below:
Note: Here I deleted the value of the ‘Last N Days‘ field and changed the metric ga:goalXXValue to ga:goal4Value.
Step-5: Again navigate to Add-ons menu > Google Analytics > ‘Run Reports‘:
If there is no error in any of your query parameters, you will get a ‘completed successfully’ report status like the one below:
If there is an error in one of your query parameters, you will get a ‘report failed’ report status like the one below:
Note: You are less likely to get errors if you build your queries through query explorer (instead of manually) before you start using GA Spreadsheet add on.
Step-6: Click on the ‘ok’ button of the ‘Report Status’ dialog box:
If there is no error in your query parameters then you will see a new tab added to your Google spreadsheet.
This tab contains your new report:
Note the data from this report matches with the Google Analytics report:
This is proof that you correctly downloaded data from Google Analytics into Google Sheets via the Google Analytics Spreadsheet add-on.
Related Article: How to use Google Analytics Real-Time Reporting API
Other Web Analytics Tools
- How to use Keyword Hero to reveal Not Provided keywords in Google Analytics
- Regular Expressions Guide for Google Analytics and Google Tag Manager
- Beginners Guide to Coding for SEO & Web Analytics
- Google Analytics Usage Trends Tool
- Why you may no longer need Google Tag Manager
- Optimize Smart Web Analytics Tool Box
- Best Google Analytics Shortcuts: Tricks, Tools & APIs to save Time
- Excel for SEO & Analytics – Powerful Cheat Sheet
Frequently Asked Questions About How to use Google Analytics API Without Any Coding
What is an API?
An application programming interface (or API) is the interface between two program modules. This interface is made up of sets of routines, protocols, and tools.
Through an API you can:
– Create new software applications.
– Integrate your application with a third party application.
– Enhance the functionality of an existing application.
What APIs does Google Analytics provide?
Google Analytics provides two types of APIs:
– Management API
– Core Reporting API
Through management API you can access information related to your Google Analytics accounts (like account ID), web properties and views. To access the actual report data (like sessions, pageviews, bounce rate, etc) you need to use the Core Reporting API.
Do I have to write code to access the Google Analytics API?
Not necessarily! Writing code that can make API calls is not easy. So in order to facilitate this process, there are a number of third-party tools out there (like Analytics Canvas) that make it possible to directly interact with Google Analytics APIs without writing any program. In this article, I will show you how to access Google Analytics APIs without doing any coding via the Google Analytics Spreadsheet add-on
What is the Google Analytics Dimensions and Metrics Explorer?
The Google Analytics Dimensions and Metrics Explorer tool lists and explains all of the dimensions and metrics available via the Core reporting API.
It also tells you which dimensions and metrics can be queried/used together. Not all dimensions and metrics can be queried together.
https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/
My best selling books on Digital Analytics and Conversion Optimization
Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.
Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.
Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.
Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.