Tidy Up Your Google Analytics Data for Better Customer Analytics

DZone 's Guide to

Tidy Up Your Google Analytics Data for Better Customer Analytics

Google Analytics is the standard for collecting data on traffic. However it is, by default, poorly configured to handle all but the most basic tasks. Treasure Data is a new tool that handles that data and more—allowing you to finally tidy up your analytics.

· Big Data Zone ·
Free Resource

Google Analytics: Yet Another Data Silo?

For digital marketers, Google Analytics needs no introduction. It’s the most popular analytics tool and often the first to be introduced to a company’s martech stack.

Google Analytics is a powerful tool by its own right. It makes it easy to get started on basic metrics. Advanced users can customize user segments and run multi-touch and multi-device attribution analysis. Finally, it is completely free until you decide to go enterprise (See this blog for the comparison among different analytics tools).

But here is Google Analytics’ limitation: it does not hold all data that you need to do your analysis. In other words, it’s yet another data silo you need to pull your data from.

While we marketers rely heavily on Google Analytics to make decisions, it is hardly the only data source. Here are examples of other data sources:

  • Ad performance data: Many companies advertise on multiple platforms: Google AdWords, Twitter Ads, Facebook and Instagram Ads, Bing Ads and so on. Doing analysis across these platforms is time-consuming, error-prone and exhausting.
  • Mobile and web product usage data: Many SaaS and E-Commerce marketers fail to measure the real ROI of their customer acquisition campaigns because they fail to incorporate product usage data into their analysis. Product usage data is often buried deep in databases and log files and is not exactly accessible for marketers (and hence not captured in Google Analytics or similar analytics tools).

Treasure Data as a Marketing Analyst’s Data Hub

Treasure Data provides a solid foundation to collect data coming from multiple data sources. Our 300+ connectors help both developers and marketers collect data into a single view, allowing your team to create an end-to-end customer profile view.

In the rest of this blog, I will show you how to import any report into Treasure Data in an automated fashion. The only things you need are Google and Treasure Data accounts, as well as a willingness to configure our pre-built script.

Importing Google Analytics Reports into Treasure Data: Step-by-Step

Get all necessary parameters. You need the following parameters:

  1. Google Analytics Profile ID
  2. Treasure Data API key
  3. Standalone Google Script Service with Analytics API enabled.

To get the Google Analytics Profile ID, go to the “Admin” tab and select the Account/Property/View combination that you want to report on. Then, check the URL of the page. The URL should look like:

 What you need is <PROFILE_ID> here.

Next, you need to get Treasure Data’s API key. After signing up for the service, follow the instructions here to get the API key.

Finally, you need to get an instance of Google Script.

1. Make sure that you are logged in with your Google account with access to your Google Analytics.

2. Visit https://console.developers.google.com and enabled the Analytics API from here.

3. Visit https://script.google.com and create a new standalone Google AppScript

4. Copy and paste this script into Google Script Editor.

5. The first several lines of the script needs to be configured by updating the values in the INPUT JSON. The definitions of the INPUT fields are as follows:

  • groupBy: The array of dimensions to group by the report. The full list of available dimension names is here. To save you some typing, the leading “ga:” can be omitted.
  • metrics: The array of measures/metrics to report. The full list of available metrics names is here. Again, no need to have the “ga:” prefix.
  • sortBy: The array of dimensions and metrics to sort by.
  • profileId: This is the Google Analytics Profile ID that you retrieved earlier.
  • databaseName: The name of the Treasure Data database.
  • tableName: The name of the Treasure Data table.
  • tdAPIKey: The Treasure Data API key that you retrieved earlier.

6. Select the “main” function from the dropdown and import data into Treasure Data: IMAGE

7. Check that the report was successfully imported into Treasure Data. It may take up to one minute for the data to become available.

And there’s your Google Analytics report data! Thanks to Google Analytics’ Core Reporting API, myriad reports can be imported into Treasure Data. See this page to learn more about customizing your reports.

8. Optionally, you can use Google Script’s Trigger function to automate the process. To do this, go to “Resources” -> “Current project’s triggers” -> “Add a new trigger”.

Now, this import will happen every night between 1am and 2am.

analytics, google analytics, reporting

Published at DZone with permission of Kiyoto Tamura , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}