AWS

Tutorials

How to Combine Google Analytics and Google Ads Data for Comprehensive Campaign Analysis

Overview

Have you ever wished that you could run analytics on your Google Analytics and Google Ads data all in the same place? In this post, you will learn how to combine your data from Google Analytics and Google Ads. This could be useful if you wanted to explore how your campaigns are performing and see the effect of each campaign on your website or other tracked events in Google Analytics. Combining data from these two sources can enrich your analysis and gain a deeper understanding of each campaign’s performance from multiple perspectives. This approach allows for more granular insights, helping you determine which campaigns work best and how they impact user behavior.

Syncing Your Google Data and Your Google Ads Data

If you are new to CloudQuery, follow the instructions on the Downloads page to install the CloudQuery CLI and get started with syncing your data.

First, we will sync data using the Google Analytics plugin. Note that for this specific plugin, Google Analytics tables are auto-generated from the database schema. Therefore, you need to specify the dimensions and metrics manually. Below is a sample configuration:

kind: source
spec:
name: googleanalytics
path: cloudquery/googleanalytics
registry: cloudquery
version: "v4.3.3"
tables: ["*"]
destinations: ["postgresql"]
backend_options:
table_name: "cq_state_googleanalytics"
connection: "@@plugins.postgresql.connection"

spec:
property_id: ""
oauth:
access_token: ""
reports:
- name: example
dimensions:
- campaignId
- campaignName
- sourceMedium
- date
- language
- country
- city
- googleAdsCampaignId
- deviceCategory
metrics:
- name: Sessions
- name: totalUsers
- name: screenPageViews
- name: averageSessionDuration
- name: bounceRate
- name: transactions
- name: purchaseRevenue
- name: activeUsers
- name: newUsers
keep_empty_rows: true

For this task, we also use CloudQuery with the Google Ads plugin. Ensure that the googleads_campaigns table is in your database.

You can export Google Ads data to PostgreSQL (or other listed data destinations) for analysis. We will use PostgreSQL for our example.

Query to Combine Data

The following SQL query can be used to join your Google Analytics and Google Ads data based on your campaign ID:

SELECT
ga.date,
ga.dimensions->>'campaignName' AS campaign_name,
ga.dimensions->>'sourceMedium' AS source_medium,
ga.dimensions->>'deviceCategory' AS device_category,
ga.dimensions->>'country' AS country,
ga.dimensions->>'city' AS city,
ga.metrics->>'Sessions' AS sessions,
ga.metrics->>'totalUsers' AS total_users,
ga.metrics->>'screenPageViews' AS pageviews,
ga.metrics->>'averageSessionDuration' AS avg_session_duration,
ga.metrics->>'bounceRate' AS bounce_rate,
ga.metrics->>'transactions' AS transactions,
ga.metrics->>'purchaseRevenue' AS revenue,
gad.name AS google_ads_campaign_name,
gad.customer_id,
gad.advertising_channel_type,
gad.start_date AS google_ads_start_date,
gad.end_date AS google_ads_end_date,
gad.status AS google_ads_status,
gad.campaign_budget AS google_ads_campaign_budget
FROM
public.ga_example ga
JOIN
googleads_campaigns gad
ON
ga.dimensions->>'googleAdsCampaignId' = gad.id::text;

This query joins the two tables you created using CloudQuery's Google Analytics and Google Ads plugins. The join is based on the campaign ID common to both tables, allowing us to extract relevant columns from both. The metrics and dimensions in the ga_example table are stored as JSON data, so we must extract the values properly.

Example Results

datecampaign_namesource_mediumdevice_categorycountrycitysessionstotal_userspageviewsavg_session_durationbounce_ratetransactionsrevenuegoogle_ads_campaign_namecustomer_idadvertising_channel_typegoogle_ads_start_dategoogle_ads_end_dategoogle_ads_statusgoogle_ads_campaign_budget
2024-07-31 00:00:00Summer Salegoogle / cpcmobileUSANew York100090015003000.5505000Summer Sale123456789SEARCH2024-06-012024-12-31ENABLED1200000
2024-08-01 00:00:00Winter Salegoogle / cpcdesktopUSASan Francisco80070012002500.6303000Winter Sale123456789DISPLAY2024-07-012024-11-30PAUSED800000
2024-08-02 00:00:00Spring Salegoogle / cpctabletUSALos Angeles1200110018003200.4606000Spring Sale123456789SEARCH2024-08-012024-10-31ENABLED1500000

Summary

By combining Google Analytics and Google Ads data, you can gain a better understanding of your campaigns, getting more information for each campaign that is not available by using just one table. Feel free to adjust the dimensions and metrics to suit your specific needs, and use the provided SQL query as a starting point for your analysis. If you want to enhance your data analysis capabilities, try CloudQuery for free or connect with our engineering team for further assistance.

Want help getting started? Join the CloudQuery community to connect with other users and experts, or message our team directly here if you have any questions.

Try CloudQuery yourself

Self-hosted, open source, and free to start. Or schedule a demo to see the managed version.

Related posts

AWS

Security

Tutorials

Finding AWS Unrestricted Outbound Access in 2026: EC2, Lambda, and Beyond

Find EC2, Lambda, and ECS Fargate resources with unrestricted outbound access in AWS using SQL. Why egress controls still break attack chains in 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Security

Tutorials

AWS IAM Identity Center with Google Workspace as an IdP: 2026 Step-by-Step Guide

Set up AWS IAM Identity Center with Google Workspace: SAML authentication, SCIM user provisioning, and group sync with CLI or ssosync. Updated for 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Cloud Infrastructure

Security

Tutorials

Integrate AbuseIPDB Threat Intelligence with CloudQuery

Enrich your cloud asset inventory with AbuseIPDB threat intelligence to identify public cloud IPs with known abuse reports.

Joe Karlsson

Joe Karlsson

April 20, 2026

AWS

Cloud Infrastructure

Tutorials

How to Query ipinfo.io Data with CloudQuery

Learn how to enrich your cloud asset inventory with ipinfo.io IP geolocation and threat intelligence data using CloudQuery.

Joe Karlsson

Joe Karlsson

April 20, 2026

AWS

Security

Tutorials

AWS IAM Identity Center (Formerly AWS SSO): The Complete 2026 Guide

AWS IAM Identity Center replaced AWS SSO in 2022. Learn how to set it up, configure permission sets, use the AWS CLI, and audit access with CloudQuery.

Joe Karlsson

Joe Karlsson

April 6, 2026

AWS

Tutorials

AWS Pinpoint Is Being Deprecated: How to Assess Your Migration Scope

AWS Pinpoint reaches end of support October 2026. Query your Pinpoint usage across all accounts to find what needs migrating before the deadline.

Joe Karlsson

Joe Karlsson

March 24, 2026

AWS

Best Practices

Tutorials

CloudQuery Sync Performance: A Practical Troubleshooting Guide

Diagnose why CloudQuery syncs slow down after plugin upgrades, identify expensive tables, and use the CLI command that replaces the tables wildcard.

Joe Karlsson

Joe Karlsson

March 6, 2026

AWS

Security

Tutorials

Set Up AWS CLI with SSO (IAM Identity Center) — Step by Step

Set up AWS CLI v2 with IAM Identity Center in 5 minutes. Covers SSO registration scopes, sso-session config, token refresh, and multi-account profiles.

Yevgeny Pats

Yevgeny Pats

February 25, 2026

AWS

Cloud Infrastructure

Tutorials

AWS Lambda Python 3.9 End-of-Support: Find and Upgrade Every Affected Function

AWS Lambda Python 3.9 security patches stopped Dec 15, 2025. Find every affected function across all accounts with SQL queries and upgrade to 3.12 or 3.13.

Joe Karlsson

Joe Karlsson

February 10, 2026

Own your pipeline.
Own your data.