How to handle Google Analytics data in BigQuery

Preface

Google Analytics is widely used in various industries for tracking user activities in Web and mobile applications. For most of the users, the default reporting provided by GA is usually sufficient as long as the tracking of the application is in place (If not, go for the custom reporting! :p ).

Yet, once the business grows into a certain scale (20–50 employees or even bigger), there comes to a need to have the GA data available in a Data Warehouse for further in-depth analysis and even Machine Learning purposes.

Setup

The GA public data from BigQuery is used in the illustration:

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`

And the preview of the data would be looking like this:

The blanks come from the ARRAY, which we will discuss later

And for the ease of demonstration, we would also assume that the Data Warehouse is on BigQuery instead of the other tech (e.g. Redshift or Snowflake).

It would be very nice if you have a GCP (Google Cloud Platform) project up & running already, so you could follow this guideline to gain a better understanding.

Getting Started — Build a View in the Data Layer

The official documentation from Google can be found here: GA BigQuery Export schema.

The highlights are the visitStartTime column and the name of the table bigquery-public-data.google_analytics_sample.ga_sessions_20170801. In short, the naming pattern of the BigQuery tables is {GCP project name}.{Dataset name}.{Table name}.

As for BigQuery tables from the native export from GA, they are actually Shaded Tables. Shaded Tables basically mean that they are all different table objects, but following the exact same naming convention.

In this context, it would be the a series of tables like this:

  • bigquery-public-data.google_analytics_sample.ga_sessions_20170801
  • bigquery-public-data.google_analytics_sample.ga_sessions_20170731
  • bigquery-public-data.google_analytics_sample.ga_sessions_20170730

etc.

How does it look like for Shaded Tables in BigQuery Web Console

To query one of the tables, the code is pretty simple:

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`

Interesting question: What would you do if you wanna query more than 1 table with the exact same schema?

Answer: UNION ALL

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`

UNION ALL
SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170731`

The query above allows us to query data from 31 July to 1 August 2017. But obviously it doesn’t help a lot with actual business use cases. We would need MUCH more data than 2 days.

To tackle this, BigQuery provides the solution of Wildcard Tables. It means we could do something like this:

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`

Yup, the magic is the * after the ga_sessions_.

A general business user would think this is good enough already. But for a data professional (especially a data engineer), it isn’t.

To make it more maintainable and more readable by humans, we need 2 more columns here: created_at & created_date.

Why? Because the schema of the GA tables doesn’t come with the date with the DATE format. The date column in the tables is in STRING format. To align with the partitioning of the other tables in the Data Warehouse, the columns created_date and created_at are necessary.

Here is a sample query of running against the GA tables:

WITH ga_data AS (
  SELECT PARSE_DATE('%Y%m%d', _TABLE_SUFFIX) AS created_date
    , TIMESTAMP_SECONDS(visitStartTime) AS created_at
    , *
  FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`
)
SELECT *
FROM ga_data
WHERE 1=1
  AND created_date = '2017-08-01'

The basic idea here is to leverage the non-materialistic nature of CTEs in BigQuery, and make it easier to build queries on top of it.

PARSE_DATE (Reference here) is a function taking a STRING value and return a DATE value. In this case, we are using the suffix of the Shaded Tables and cast it to DATE. By doing so, we could easily control which date’s data to fetch and to play with.

Assuming we have a dataset in the GCP project named dl as Data Layer, we could create the View with DDL for the GA data here:

CREATE OR REPLACE VIEW `dl.ga_sessions`
AS

SELECT PARSE_DATE('%Y%m%d', _TABLE_SUFFIX) AS created_date
  , TIMESTAMP_SECONDS(visitStartTime) AS created_at
  , *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`

To consume data from the view, just simply run this query:

SELECT *
FROM `dl.ga_sessions`
WHERE 1=1
  AND created_date = '2017-08-01'

Note that the project name is not a must in the query. If it is omitted, BigQuery would fallback to the GCP project that you are running the query in and look for the View there.

#google-analytics #arrays #data-science #bigquery #data #data analysis

What is GEEK

Buddha Community

How to handle Google Analytics data in BigQuery
Siphiwe  Nair

Siphiwe Nair

1620466520

Your Data Architecture: Simple Best Practices for Your Data Strategy

If you accumulate data on which you base your decision-making as an organization, you should probably think about your data architecture and possible best practices.

If you accumulate data on which you base your decision-making as an organization, you most probably need to think about your data architecture and consider possible best practices. Gaining a competitive edge, remaining customer-centric to the greatest extent possible, and streamlining processes to get on-the-button outcomes can all be traced back to an organization’s capacity to build a future-ready data architecture.

In what follows, we offer a short overview of the overarching capabilities of data architecture. These include user-centricity, elasticity, robustness, and the capacity to ensure the seamless flow of data at all times. Added to these are automation enablement, plus security and data governance considerations. These points from our checklist for what we perceive to be an anticipatory analytics ecosystem.

#big data #data science #big data analytics #data analysis #data architecture #data transformation #data platform #data strategy #cloud data platform #data acquisition

Gerhard  Brink

Gerhard Brink

1620629020

Getting Started With Data Lakes

Frameworks for Efficient Enterprise Analytics

The opportunities big data offers also come with very real challenges that many organizations are facing today. Often, it’s finding the most cost-effective, scalable way to store and process boundless volumes of data in multiple formats that come from a growing number of sources. Then organizations need the analytical capabilities and flexibility to turn this data into insights that can meet their specific business objectives.

This Refcard dives into how a data lake helps tackle these challenges at both ends — from its enhanced architecture that’s designed for efficient data ingestion, storage, and management to its advanced analytics functionality and performance flexibility. You’ll also explore key benefits and common use cases.

Introduction

As technology continues to evolve with new data sources, such as IoT sensors and social media churning out large volumes of data, there has never been a better time to discuss the possibilities and challenges of managing such data for varying analytical insights. In this Refcard, we dig deep into how data lakes solve the problem of storing and processing enormous amounts of data. While doing so, we also explore the benefits of data lakes, their use cases, and how they differ from data warehouses (DWHs).


This is a preview of the Getting Started With Data Lakes Refcard. To read the entire Refcard, please download the PDF from the link above.

#big data #data analytics #data analysis #business analytics #data warehouse #data storage #data lake #data lake architecture #data lake governance #data lake management

Ian  Robinson

Ian Robinson

1624399200

Top 10 Big Data Tools for Data Management and Analytics

Introduction to Big Data

What exactly is Big Data? Big Data is nothing but large and complex data sets, which can be both structured and unstructured. Its concept encompasses the infrastructures, technologies, and Big Data Tools created to manage this large amount of information.

To fulfill the need to achieve high-performance, Big Data Analytics tools play a vital role. Further, various Big Data tools and frameworks are responsible for retrieving meaningful information from a huge set of data.

List of Big Data Tools & Frameworks

The most important as well as popular Big Data Analytics Open Source Tools which are used in 2020 are as follows:

  1. Big Data Framework
  2. Data Storage Tools
  3. Data Visualization Tools
  4. Big Data Processing Tools
  5. Data Preprocessing Tools
  6. Data Wrangling Tools
  7. Big Data Testing Tools
  8. Data Governance Tools
  9. Security Management Tools
  10. Real-Time Data Streaming Tools

#big data engineering #top 10 big data tools for data management and analytics #big data tools for data management and analytics #tools for data management #analytics #top big data tools for data management and analytics

How to handle Google Analytics data in BigQuery

Preface

Google Analytics is widely used in various industries for tracking user activities in Web and mobile applications. For most of the users, the default reporting provided by GA is usually sufficient as long as the tracking of the application is in place (If not, go for the custom reporting! :p ).

Yet, once the business grows into a certain scale (20–50 employees or even bigger), there comes to a need to have the GA data available in a Data Warehouse for further in-depth analysis and even Machine Learning purposes.

Setup

The GA public data from BigQuery is used in the illustration:

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`

And the preview of the data would be looking like this:

The blanks come from the ARRAY, which we will discuss later

And for the ease of demonstration, we would also assume that the Data Warehouse is on BigQuery instead of the other tech (e.g. Redshift or Snowflake).

It would be very nice if you have a GCP (Google Cloud Platform) project up & running already, so you could follow this guideline to gain a better understanding.

Getting Started — Build a View in the Data Layer

The official documentation from Google can be found here: GA BigQuery Export schema.

The highlights are the visitStartTime column and the name of the table bigquery-public-data.google_analytics_sample.ga_sessions_20170801. In short, the naming pattern of the BigQuery tables is {GCP project name}.{Dataset name}.{Table name}.

As for BigQuery tables from the native export from GA, they are actually Shaded Tables. Shaded Tables basically mean that they are all different table objects, but following the exact same naming convention.

In this context, it would be the a series of tables like this:

  • bigquery-public-data.google_analytics_sample.ga_sessions_20170801
  • bigquery-public-data.google_analytics_sample.ga_sessions_20170731
  • bigquery-public-data.google_analytics_sample.ga_sessions_20170730

etc.

How does it look like for Shaded Tables in BigQuery Web Console

To query one of the tables, the code is pretty simple:

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`

Interesting question: What would you do if you wanna query more than 1 table with the exact same schema?

Answer: UNION ALL

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`

UNION ALL
SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170731`

The query above allows us to query data from 31 July to 1 August 2017. But obviously it doesn’t help a lot with actual business use cases. We would need MUCH more data than 2 days.

To tackle this, BigQuery provides the solution of Wildcard Tables. It means we could do something like this:

SELECT *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`

Yup, the magic is the * after the ga_sessions_.

A general business user would think this is good enough already. But for a data professional (especially a data engineer), it isn’t.

To make it more maintainable and more readable by humans, we need 2 more columns here: created_at & created_date.

Why? Because the schema of the GA tables doesn’t come with the date with the DATE format. The date column in the tables is in STRING format. To align with the partitioning of the other tables in the Data Warehouse, the columns created_date and created_at are necessary.

Here is a sample query of running against the GA tables:

WITH ga_data AS (
  SELECT PARSE_DATE('%Y%m%d', _TABLE_SUFFIX) AS created_date
    , TIMESTAMP_SECONDS(visitStartTime) AS created_at
    , *
  FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`
)
SELECT *
FROM ga_data
WHERE 1=1
  AND created_date = '2017-08-01'

The basic idea here is to leverage the non-materialistic nature of CTEs in BigQuery, and make it easier to build queries on top of it.

PARSE_DATE (Reference here) is a function taking a STRING value and return a DATE value. In this case, we are using the suffix of the Shaded Tables and cast it to DATE. By doing so, we could easily control which date’s data to fetch and to play with.

Assuming we have a dataset in the GCP project named dl as Data Layer, we could create the View with DDL for the GA data here:

CREATE OR REPLACE VIEW `dl.ga_sessions`
AS

SELECT PARSE_DATE('%Y%m%d', _TABLE_SUFFIX) AS created_date
  , TIMESTAMP_SECONDS(visitStartTime) AS created_at
  , *
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`

To consume data from the view, just simply run this query:

SELECT *
FROM `dl.ga_sessions`
WHERE 1=1
  AND created_date = '2017-08-01'

Note that the project name is not a must in the query. If it is omitted, BigQuery would fallback to the GCP project that you are running the query in and look for the View there.

#google-analytics #arrays #data-science #bigquery #data #data analysis

Big Data Analytics: Unrefined Data to Smarter Business Insights - TopDevelopers.co

For Big Data Analytics, the challenges faced by businesses are unique and so will be the solution required to help access the full potential of Big Data.
Let’s take a look at the Top Big Data Analytics Challenges faced by Businesses and their Solutions.

#big data analytics challenges #big data analytics #data management #data analytics strategy #business solutions by big data #top big data analytics companies