{"id":5742,"date":"2023-09-13T00:12:51","date_gmt":"2023-09-12T21:12:51","guid":{"rendered":"https:\/\/trackingchef.com\/?p=5742"},"modified":"2023-09-14T11:02:39","modified_gmt":"2023-09-14T08:02:39","slug":"exporting-google-analytics-ua-data-to-google-sheets","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/google-analytics\/exporting-google-analytics-ua-data-to-google-sheets\/","title":{"rendered":"Exporting Google Analytics UA data to Google Sheets"},"content":{"rendered":"\n

With the sunset of Google Analytic Universal (aka UA), many sites not only had to migrate their tracking to GA4 but also are now dealing with exporting the data from their legacy accounts.<\/p>\n\n\n\n

Google has stated that the data in legacy accounts will be retained for another year (July 2024), so marketers need to find a solution for exporting their important data ahead of that.<\/p>\n\n\n\n

In this guide, I’ll walk you through one option for retaining your data using Google Sheets and the Google Analytics Add-on for Google Sheets.<\/p>\n\n\n\n

Rationale<\/h2>\n\n\n\n

Exporting the GA UA data is important. That being said, not all the data we have in GA counts. We don’t want to export data that is too old or too granular. How old is too old and how granular is too granular? That’s up to you to decide.<\/p>\n\n\n\n

Additionally, there are fancier ways to pull the data. You can plug into BigQuery or any other database to run fancy SQL on top.<\/p>\n\n\n\n

I believe most businesses won’t need this and can settle for a quick manual export that will retain the key data points they need to understand year-over-year trends.<\/p>\n\n\n\n

My suggestion is to do this manual export once (will take ~2 hours probably), using free tools such as Google Sheets, the Google Analytics Add-on for Sheets, and Looker Studio.<\/p>\n\n\n\n

Step 1: Map the data you want to export<\/h2>\n\n\n\n

Before we dive into the technical details, we need to understand what data we want to pull from GA.<\/p>\n\n\n\n

In Universal Analytics, the data is aggregated in tables, so the data structure is set in advance, for better or worse.<\/p>\n\n\n\n

This means that we can only pull a certain level of granularity of the data. For example, any data fetched will be aggregated within a specific date range – a day, week, or month.<\/p>\n\n\n\n

The data is formatted in the classic GA UA schema with Dimensions and Metrics.<\/p>\n\n\n\n

Classic combinations for exporting are usually:<\/p>\n\n\n\n

Dimensions<\/strong><\/td>Metrics<\/strong><\/td><\/tr>
Source\/Medium, Campaign, Landing page<\/td>Users, Sessions, Avg. Time on site, Conversions (all or specific)<\/td><\/tr>
Page path<\/td>Pageviews, Unique Pageviews, Avg. Time on page<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

Important – Add the date dimension so you can later reference a specific day in your dashboard.<\/p>\n\n\n\n

Step 2: Create a new Google Sheet and install the add-on<\/h2>\n\n\n\n

To start the export, create a new Google Sheet (you can do this by navigating to sheets.new<\/a>).<\/p>\n\n\n\n

In the new sheet, click on Extensions -> Add-ons -> Get add-ons<\/p>\n\n\n\n

Search for Google Analytics<\/em> and add the pone on the top left-hand side (see screenshot).<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Step 3: Configuring the add-on<\/h2>\n\n\n\n

After installing the add-on, you can create a new report by navigating to Extensions -> Google Analytics -> Create new report. This will open a new sidebar in your Google Sheets document.<\/p>\n\n\n\n

The report configuration can be set once using the wizard. Simply select the account, property, and specific view you want the data to be pulled from.<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

Next, select the specific metrics and dimensions you want to report on from the dropdown.<\/p>\n\n\n\n

The output of the wizard is a screenshot below, which lists the specific View ID (more specific than property ID), the date range for the report, and the API names of the metrics and dimensions selected.<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

The report can now be run by navigating to Extensions -> Google Analytics -> Run report. If the report setup is valid, it will create a new tab with the name of the report and paste in the data from this report’s run. If a tab with this name already exists (i.e. this report has already been run) any existing data will be overwritten.<\/p>\n\n\n

\n
\"\"
The report summary<\/figcaption><\/figure><\/div>\n\n\n

After running the report, you will see the report summary and the data table.<\/p>\n\n\n\n

Important – Make sure that the report doesn’t contain any sampled data else it will be significantly less accurate. If that happens, try querying a shorter time frame.<\/p>\n\n\n\n

Step 4: Editing the report<\/h2>\n\n\n\n

This is one of the caveats of this add-on: the wizard can only be used when creating a new report. Additional edits to the report must be done by manually changing the values in the report configuration.<\/p>\n\n\n\n

Report configuration<\/h3>\n\n\n\n

View ID – Don’t change this unless you want to fetch data from a different view. The view ID can be found in the view settings tab in the GA admin.<\/p>\n\n\n\n

Start date – This can be set to a specific date (MM-DD-YYYY format) or explicit strings such as 30daysAgo, 7daysAgo, today, or yesterday.<\/p>\n\n\n\n

End date – Same as start date. Must be equal or later than the start date else the report will fail.<\/p>\n\n\n\n

Metrics & Dimensions – The full list of metrics and dimensions can be found here in Google’s Explorer<\/a>. It also shows which pairs can be matched under the same scope to avoid data clashes.<\/p>\n\n\n\n

Order – This is the sorting that will be applied to the report. Add any metric or dimension, and add a minus sign to indicate descending order. Multiple dimensions and metrics can be used with a comma.<\/p>\n\n\n\n

Segments & Filters – These can be used to pull specific data, e.g. only organic traffic, which in our case isn’t important.<\/p>\n\n\n\n

Step 5: Exporting the data<\/h2>\n\n\n\n

Once we have our report configured we can start the manual labor.<\/p>\n\n\n\n

We can set the report to extract 1-3 months of data for the query we want. Assuming no sampling occurred, we can then copy the report’s output to a new sheet which will serve as our database. Make sure to copy the column headers too.<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

This part is critical, as the next report’s run will overwrite the data, so we need to save it elsewhere.<\/p>\n\n\n\n

Now set the report’s timeframe to the preceding 1-3 months. Run the report, check there’s no sampling, and paste the new data at the bottom of the “database” sheet. Add only the data rows, without the headers (which should be identical).<\/p>\n\n\n\n

Repeat as many times as required to cover the timeframe you want to export (e.g. 18 months).<\/p>\n\n\n\n

In the case that you want to pull multiple distinct reports (e.g. Acquisition and Content), create new tabs that will serve as “databases” for each report you want to create.<\/p>\n\n\n\n

Step 6: Visualize the data<\/h2>\n\n\n\n

Go get yourself a beer, you’ve earned it.<\/p>\n\n\n\n

After the data has been extracted, we can now visualize this data using Looker Studio (aka Data Studio). I recommend doing this early in the process (i.e. after extracting two runs of data) to make sure you have all the data points you want. Will be a bummer to have to repeat this process over a forgotten metric.<\/p>\n\n\n\n

In Looker Studio, connect a new data source from Google Sheets and select the document and specific sheet that serves as your database.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

You can now visualize the data in any way you choose, from charts to graphs and anything you imagine. The simple dashboard below is built purely from Google Sheets data extracted in this exact method.<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

Pro tip: Import to BigQuery<\/h2>\n\n\n\n

If you export a large number of rows, your database may become slow to query. If you’ve exceeded 100k rows, I recommend importing the data into Google’s BigQuery by following this great guide by Hevo Data<\/a>.<\/p>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

With the sunset of Google Analytic Universal (aka UA), many sites not only had to migrate their tracking to GA4 but also are now dealing with exporting the data from their legacy accounts. Google has stated that the data in legacy accounts will be retained for another year (July 2024), so marketers need to find […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-5742","post","type-post","status-publish","format-standard","hentry","category-google-analytics"],"_links":{"self":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/5742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/comments?post=5742"}],"version-history":[{"count":2,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/5742\/revisions"}],"predecessor-version":[{"id":5752,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/5742\/revisions\/5752"}],"wp:attachment":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media?parent=5742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/categories?post=5742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/tags?post=5742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}