How to Create Custom Reports Using the Google Analytics API

preview_player
Показать описание


Because of that lack of success, I had to go back to the drawing board. There was promise in the Google Analytics API explorer that I might be able to create this particular report using the GA API. But I wasn't going to build the report if you weren't interested in the subject matter. So, I offered to journey inside the Google Analytics API if you left enough comments.

The votes were tallied, and here we are with the second part of our Google Analytics exploration!

Here's we where started with our with custom report conundrum:
We were trying to solve a reporting problem for one of our Analytics Course students, Helgi.

Helgi needs a custom ecommerce report that includes quantity of product, revenue, the product purchased, and e-commerce conversion rate all in one report.

Unfortunately, creating this custom report in the standard Google Analytics interface did not work. Google Analytics couldn't put all these metrics together in the custom report builder because these metrics and dimensions had different scopes.

We used the Metric and Dimension Explorer to see if this report was even possible.

The conclusion was, we might be able to use the Google Analytics API to build this report.

Should we try this again in the Google Analytics API?
At the end of our last tutorial, I asked you "Do you want to learn how to use the Google Analytic API." And you answered with a resounding "YES!"

Because of your enthusiasm and support...
Today we are going inside of the Google Analytics API to learn how to build custom reports!

Building custom reports in the Google Analytics API
The easiest way to build reports in the API is with the Google Sheets Add-on.

Using the Google Sheets Add-on to work in the API

Once you click through to install the Add-on, you'll get a blank spreadsheet.

This spreadsheet is where we 'll build our custom report.

In the Add-ons menu of your Google Sheet select "Create a new report."

Building custom reports in the Google Sheets Add-on
Creating a new report will bring up a menu on the left-hand side of your screen. In this menu, you can choose the property you want to work in.

The Google Merchandise Store (GMS) is already populated with the product and sales data we need. We'll start by trying to build our report in the GMS account.

The report menu is also where you select the metrics, dimensions, and segments you want in your report.

The metrics we want in our report include quantity of product, revenue and conversion rate.

We also need the dimension: product.

Once your metrics and dimensions are set, you can select "Create Report."

Configure your custom report
Creating the report will add a configuration tab to your spreadsheet. This tab shows you the parameters of your report. It does not contain your data.

Run your report
To see our data, we need to select "Run reports" from the Google Sheets Add-ons menu.

Permission levels for the Google Analytics API
Unfortunately, attempting to run this report returned an error message. We don't have high enough permission to work in the GMS account using the API.

To create this report I need to use an account where I have the right permission level. (To learn all about Google Analytics permission and access level see our Analytics Course permissions guide.)

So we'll have to go back to square one. I'll switch over to an account that I have full access in and try to create our report again. Jumping from one property to another in the API is pretty quick and painless.

Error messages and problem solving
When I run our report from an account where I have full access in, I get shut down again. This time the error message says:

"Selected dimensions and metrics cannot be queried together."

Now, I could have edited our failed attempts to run this report out of this post and just said - "this isn't possible." But there's an important lesson here that I wanted to share with you.

Sometimes you don't absolutely know what you can and can't do until you try.

And...

Just because you can dream it, doesn't mean Google Analytics can do it
Not everything you can think up is something you can do in Google Analytics. In our previous post on custom reports, we used the dimensions and metrics explorer to see if this report was even possible. Google told us it was possible, so we moved to the next stage.

Not all metrics and dimension work together, even in the API
In this tutorial, we configured our report using the Google Analytics API.

Рекомендации по теме
Комментарии
Автор

Yes sir! please show us more on that subject, + what do i do if i don't have real traffic to work on? how can i practice making reports? thank you!

yinimin
Автор

Hey Jeff thanks you very much for the detailed Can you let us know what is difference between BigQuery Data and GA data many people don't use GA and query the data from BQ as its considered more accurate.

KevinAnchi
Автор

Hi,

can you please explain how to write a filter with following details:
1. Records should only include the "Device Category" dimension is "mobile".
2. How do you indicate where the records are exclusive or inclusive.


and another question is the data sampled or not while dealing with 2 - 3 year data range.

Thanks,
Kishore

kishorekumarc
Автор

Awesome awesome Jeff! Thanks for sharing

lead-fire-agency
join shbcf.ru