Google Data Studio Tutorial with JSON

Google Data Studio, like Google Analytics, is a dashboard and reporting tool to aggregate important data.

Garrett Vorce
DataDrivenInvestor

--

Why use Google Data Studio over Google Analytics when tracking information with the web?

Unfortunately, Google Analytics can be unreliable. With the increase of ad, tracking, and cookie blocking, Google Analytics can suffer from 25% up to 50%+ of its data — being events, page views, etc — from being tracked.

This can be solved through various methods such as pixel generation to find the percentage of users with ad blockers that stop Google Analytics and/or Google Tag Manager from executing, and thus tracking.

In my case, I had Google Analytics and an external source with the same event tracking with over 40% difference between the two sources. This sounds like a large number, but is likely on the lower side, especially depending on the age target of the website.

2 day period results of tracking allowed and blocked GA and GTM scripts.

I went along and followed this guide to find the real numbers.

TL;DR (Too long, didn’t read): This script generates a transparent 1x1 pixel image that then, sends data to an internal PHP script. Depending on whether Google Analytics or Google Tag Manager has been loaded correctly, the events will populate respectively.

From the PHP script, it will send an event (Blocked or Allowed) to a specified Google Analytics account.

Google Data Studio provides various connectors that I will refer to later in the article.

Data Structure

There are various ways about structuring data for Google Studio to use. For my examples, I will use JSON as it is the easiest to understand in terms of separate entities.

Data

Let’s have a look at some real-life data! We see our data below having an array of objects with ascending timestamps correlating to their dates.

{  
"data":[
{
"date": "20181201",
"views": 100000
},
{
"date": "20181202",
"Views": 120000
},
{
"date": "20181203",
"views": 150000
}
]
}

Later on, we can choose a .json file to read from, or an external source that supplies application/json content.

For now, copy the code above and create a new file on your computer called data.json and paste. Next, go to Google Drive and upload that file in your; any subfolder is okay, just make sure to remember the full path of the file.

Setup

Before starting, set up a blank Data Studio projects here.

In the bottom corner, you will see a button [CREATE NEW DATA SOURCE]. After clicking it, you will likely be overwhelmed with a ton of different connector options.

Stay with me — it’s not as complicated as you think. What we want is called Custom JSON/CSV/XML. Next, click [SELECT] and then we’re on to our final steps of creating a data connector.

Options

Again, unfortunately, Google Data Studio and it’s newer products can be very overwhelming for newcomers.

You only need to select the JSON Data type and your Google Drive path where you stored your data.json file.

Connecting

Finally, connect your data! This allows Google Data Studio to subquery your data through various methods such as a sum of all views and filter data through dates.

Assuming you followed through each of the steps, you should see this final screen with information about your data, including fields and the data types.

Finally, add the data to your report:

Now that our data is connected to the report, we need a way to visualise it.

By selecting the table and dragging to your preferred size, the data automatically populates and allows you to interact with ascending/descending arrows.

This is a very basic example of connecting data. As you could imagine, you can filter through date ranges, use custom calculations and warnings for a more analytic-approach to your custom dashboard.

Thanks for reading, consider giving me some claps if you enjoyed this type of content.

Follow me for future articles about new technologies and tutorials!

--

--