Export Raw Hit Level Google Analytics Data to PostgreSQL

Sumit Mudliar
Electrik.AI
Published in
4 min readSep 29, 2020

What is Google Analytics?

Google Analytics (GA) is a free tool provided by Google to capture visitor insights from your website. It can track the source of the visitor, pages visited and other activities. If you have setup your GA script on your website, then it sends information to Google Analytics.

What is PostgreSQL ?

PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads

How to Export Hit Level Google Analytics Data?

Exporting raw hit-level data out of Google Analytics is very tricky because Google Analytics only makes aggregated data available from the API. Effectively, we end up downloading a Google Analytics report with each request. While we could find out the number of visitors in a particular segment on a particular day on our website and fetch a variety of metrics for those users (such as source/medium, browser, or session duration), we couldn’t get at the underlying, user-level data to follow an individual user’s journey.

Even the Premium version of Google Analytics also known as Google Analytics 360 does not give you the option to export Google Analytics Data to PostgreSQL database, You can try building your own solution but then you should be an expert in Google Analytics API, Transforming data received in JSON from Google Analytics to SQL Statements and then execute these SQL statements in your PostgreSQL database, and this is just the beginning, you must keep in mind that technologies like Google Analytics are evolving and you might find what was working yesterday might not work today. Trust me we have been following this space closely.

And so far we have just scratched the surface on how you can extract raw data from Google Analytics. It gets even more complicated when you integrate data from different marketing sources with Google Analytics. So instead of building and maintain your own solution or paying $150,000 for Google Analytics 360.

Enter Electrik.AI !!!

Electrik.AI’s Google Analytics Hit Level Data Extractor, exports raw un-sampled hit-level data from Google Analytics to PostgreSQL in just three easy steps.

Step 1: Setup your Google Analytics Account.

Step 2: Setup your PostgreSQL Database.

Step 3: Create a data flow to Export Hit Level Google Analytics data to PostgreSQL.

Your Google Analytics hit level data for each day will be exported to PostgreSQL Database after 24 hours.

Here is a sample of hit-level data exported from Google Analytics by Electrik.AI’s Google Analytics Hit-Level Data Extractor.

You can view a list of all dimensions/metrics extracted from Google Analytics here.

Electrik.AI’s Google Analytics Hit Data Extractor, uses Google Analytics to track raw hit level data on your website and exports Google Analytics Data to PostgreSQL or any Database of your choice. Along with raw un-sampled Hit Level Data you also get the following in your data exported from Google Analytics.

  1. Hashed IP Address of the Visitor on your website.
  2. Unique Visitor ID for each user on your website.
  3. Unique Session ID for each period a user is active on your site.
  4. Client ID created and assigned by the Google Analytics cookie.
  5. Order of Pages viewed by a user in a session.

--

--

Sumit Mudliar
Electrik.AI

Transforming ideas into reality through code. Driven by purpose, fueled by curiosity. Always learning and growing.