Many companies run their Ads on the Google Platform to drive more clicks and generate more leads and sales. Scraping Google Ad Results is super useful for businesses: you can research specific keywords, analyze competitors' ads, pricing, and promotional strategies, and identify valuable keywords competitors are bidding on. After this tutorial, you will know how to spy on winning competitors' Google Ads

Scrape Google Ads data from Google search

We offer two APIs for developers to scrape ads from Google:

Once you find an ad you want to look at closely, the Google Ads Transparency Center Ad Details API gives you full details for that ad, such as the headline, ad text, destination link, and the regions where it ran.

In this tutorial, we'll go through all three, from checking which competitors run ads on a keyword to pulling the full details of a single ad, with code examples in Python and Node.js.

Preparation

To begin scraping Google Ads data using our APIs, first, create a free account on serpapi.com. You'll receive 250 free search credits each month to explore the API.

Scrape Ads from Google Search results

First, let's see how to access Google Ads results in real time with the API.

Google Ads Scraper API

Preparation for accessing the SerpApi API in Python

  • Create a new main.py file
  • Install requests with:
pip install requests

Here is what the basic setup looks like:

import requests
SERPAPI_API_KEY = "YOUR_REAL_SERPAPI_API_KEY"

params = {
    "api_key": SERPAPI_API_KEY, #replace with your real API Key
    # soon
}

search = requests.get("https://serpapi.com/search", params=params)
response = search.json()
print(response)

With these few lines of code, we can access all of the search engines available at SerpApi, including the Google Ads API.

import requests
SERPAPI_API_KEY = "YOUR_SERPAPI_API_KEY"

params = {
    "api_key": SERPAPI_API_KEY, 
    "engine": "google_ads",
    "q": "best ai tools",
    "location": "Austin, Texas, United States",
}

search = requests.get("https://serpapi.com/search", params=params)
response = search.json()
print(response)

To make it easier to see the response, let's add indentation to the output.

import json

# ...
# ...
# all previous code

print(json.dumps(response, indent=2))

Here is the result from the Python code above:

Google Ads results sample

What can you extract?

Depending on the query, the API can return several sponsored result types:

  • ads: regular sponsored results from Google search pages.
  • shopping_results: sponsored shopping results.
  • local_ads: local service-style sponsored results.

The ads array can include fields such as position, block_position, title, link, displayed_link, thumbnail, tracking_link, description, source, price, rating, reviews, extensions, and sitelinks.

Scrape Data from Google Ads Transparency Center

Google Ads Transparency Center is a search engine for ads that are published through Google. It was created to empower users to make informed decisions about the ads and advertisers they see through Google - this means providing greater transparency about who the advertisers are, which ads they show, and what kind of ads are shown.

Marketers can leverage this tool as a powerful resource to analyze competitors' Google Ads and gain deeper insights into their strategies across platforms. It lets you explore ads on various topics from various companies and filter results by date, region, and creative format for more tailored results.

Google Ads Transparency Center website

SerpApi Google Ads Transparency Center API

Our Google Ads Transparency Center API allows you to scrape ad information from the Google Ads Transparency Center page.

Parts of the API Request

Search Query Parameters [At least one of these is required]

advertiser_id: Specifies the Google Advertiser ID. You can input a single ID or multiple IDs separated by commas. Alternatively, a free-text search can be performed using the text parameter.

💡
The advertiser_id is a unique identifier assigned to each advertiser within the Google Ads platform. This ID is critical in distinguishing between the different advertisers and accessing data specific to each one. 

text: Allows you to perform a search based on a specific text, often related to a domain search within the context of Google Ads. This can be used instead of the advertiser_id parameter.

💡
The text parameter offers a different way to query ads, ideal for exploring a larger pool of advertisers connected to a specific domain or name. You can use the text parameter when aiming to compare advertising strategies of multiple entities within the same industry or domain, or in cases where the specific advertiser_id is unknown.

Location Parameter

region: Sets the geographic origin of the search results. By default, it retrieves results from all regions. Head to the Google Ads Transparency Center Regions page for a full list of supported regions.

💡
The location can help in gaining insight into how advertising strategies are customized for various regions. This data is crucial for businesses looking to engage with diverse audiences. This can be accomplished through the region parameter, by filtering ad data by specific geographic areas.

Date Range Parameters

start_date: Defines the beginning date for your search, formatted as YYYYMMDD.
end_date: Sets the ending date for your search results, also in the format YYYYMMDD.

Filter Parameter

creative_format: Allows you to filter search results based on the format (e.g., text, image, video).

💡
The creative_format parameter allows you to filter ad data based on the type of creative medium used. It includes three primary options: Text, Image, and Video.

Pagination Parameters

num: Determines the maximum number of search results to be returned. In a single API request, the default is 40 and the maximum is 100.
next_page_token: Used for paginating through search results, enabling you to retrieve the next set of results.

SerpApi Parameters

engine: [Required] Set parameter to google_ads_transparency_center to use the Google Ads Transparency Center API engine.

api_key: [Required] Parameter defines the SerpApi private key to use.

There are some additional optional SerpApi parameters you can set - no_cache, async, and output, which can help you get the desired results.

You can find the API documentation here.

Parts of the API Response

The response is comprised of four parts:

search_metadata: This contains basic data about the search such as search_id, status, endpoint details, timestamps, and more.
search_parameters: This specifies which API parameters have been selected for this particular search.
search_information: This contains extra information about the search such as total number of results, and more.
ad_creatives: This contains a list of ads scraped from Google Ads Transparency Center corresponding to the search parameters.

Scrape Google Ads Transparency Center using Python

  • Start by getting your SerpApi API Key from the Manage API Key page.
  • [Optional but Recommended] Set your API key in an environment variable, instead of directly pasting it in the code. Refer here to understand more about using environment variables. For this tutorial, I have saved the API key in an environment variable named 'API_KEY'.

Example using Advertiser ID

In this instance, the code focuses on Amazon's advertising campaigns by utilizing its advertiser_id and region (region code: 2840 is USA). Here is an example in Python:

Set your params according to the parameters I mentioned above, based on which advertiser(s) and region you are looking to get ad details for.

import requests
import os, json

params = {
  "api_key": os.environ["API_KEY"],
  "engine": "google_ads_transparency_center",
  "advertiser_id": "AR12815412684405080065",
  "region": "2840"
}

search = requests.get("https://serpapi.com/search", params=params)
response = search.json()
print(json.dumps(response, indent=2))

Let's take a look at the response:

{
  "search_metadata": {
    "id": "66f748abd11195f945c1522a",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/7938d618e515f1ba/66f748abd11195f945c1522a.json",
    ...
  },
  "search_parameters": {
    "engine": "google_ads_transparency_center",
    "advertiser_id": "AR12815412684405080065",
    "region": "2840"
  },
  "search_information": {
    "total_results": 200
  },
  "ad_creatives": [
    {
      "advertiser_id": "AR12815412684405080065",
      "advertiser": "Amazon",
      "ad_creative_id": "CR07747174253753008129",
      "format": "image",
      "image": "https://tpc.googlesyndication.com/archive/simgad/325087086685235926",
      "width": 320,
      "height": 568,
      "first_shown": 1687330800,
      "last_shown": 1727477863,
      "details_link": "https://adstransparency.google.com/advertiser/AR12815412684405080065/creative/CR07747174253753008129?region=US"
    },
    ...
  ],
  "serpapi_pagination": {
    "next_page_token": "..+K6f+IlLygE=",
    "next": "..."
  }
}

By reviewing the results in the ad_creatives section, you can uncover details about Amazon's advertising approach, favored ad formats, and ad writing techniques. Not only that, you can also collect and analyze valuable ad data, including timestamps for when the ad was shown, and help businesses optimize their advertising strategies and maximize return on investment.

Example using Text

The text parameter can be used when you are looking for more generic data instead of data for specific advertisers.

Let's consider another example where we specify the text parameter and get the data from our Google Ads Transparency Center API. In this instance, the code conducts a search for Youtube related ads by utilizing the text field and region (region code: 2840 is USA). Here is an example in Python:

Set your params according to the parameters I mentioned above, based on which query of interest and region you are looking to get ad details for.

import requests
import os, json

params = {
  "api_key": os.environ["API_KEY"],
  "engine": "google_ads_transparency_center",
  "region": "2840",
  "text": "Youtube"
}

search = requests.get("https://serpapi.com/search", params=params)
response = search.json()
print(json.dumps(response, indent=2))

Let's take a look at the response:

{
  "search_metadata": {
    "id": "66f74c18cdf15587150c6ab5",
    "status": "Success",
    "json_endpoint": "https://serpapi.com/searches/c1ca1966069adace/66f74c18cdf15587150c6ab5.json",
    ...
  },
  "search_parameters": {
    "engine": "google_ads_transparency_center",
    "text": "Youtube",
    "region": "2840"
  },
  "search_information": {
    "total_results": 500000
  },
  "ad_creatives": [
    {
      "advertiser_id": "AR10629003163685879809",
      "advertiser": "Lullify Inc",
      "ad_creative_id": "CR12961410373826641921",
      "format": "text",
      "target_domain": "youtube.com",
      "image": "https://tpc.googlesyndication.com/archive/simgad/11346475487747450235",
      "width": 380,
      "height": 248,
      "first_shown": 1649270477,
      "last_shown": 1727481706,
      "details_link": "https://adstransparency.google.com/advertiser/AR10629003163685879809/creative/CR12961410373826641921?region=US&domain=Youtube"
    },
    ...
}

Example Using Start Dates and End Dates

The start_date and end_date parameters allow you to identify ad strategies over a time period. By specifying the dates, you can narrow down your search to a defined timeframe. This feature is essential for filtering ad data from particular events, such as holidays, promotional sales, or tied to specific company announcements. For example, using the dates, you could filter for ads run during a labor day weekend to see what strategies company may be using for their campaigns during that time.

Let's look at a code example to get data on ads run during labor day weekend in United States (region code: 2840) for Nike:

Playground Link: https://serpapi.com/playground?engine=google_ads_transparency_center&text=nike&region=2840&start_date=20240830&end_date=20240903

import requests
import os, json

params = {
  "api_key": os.environ["API_KEY"],
  "engine": "google_ads_transparency_center",
  "region": "2840",
  "text": "nike",
  "start_date": "20240830",
  "end_date": "20240903"
}

search = requests.get("https://serpapi.com/search", params=params)
response = search.json()
print(json.dumps(response, indent=2))

Analyzing the resulting data is useful to understand how the ads strategy changes during holiday season. Companies can gain data on how other competitors adapt ads to specific timings and they may be able to get insights into how effective these strategies are to convert ad viewers to customers.

Example using Creative Format

Ads can be created in various formats. The format can inform a lot about a company's marketing strategy and mediums of reaching their audience.

Text Ads are direct and to-the-point ways of communicating content. They are short and effective, and convey a clear message. Image Ads use visuals to engage people and create interest. Video Ads are also a useful tool to create interest using visuals but are more useful to tell a story or narrative behind a brand or product using those visuals.

Let's take a look at an example to get ads for a specific creative format. Here, I'll be getting video ads by Amazon.com Services LLC (advertiser_id: AR15974021587678527489) in United States (region ID: 2840).

import requests
import os, json

def getAdsByCreativeFormat(creativeFormat):
    params = {
    "api_key": os.environ["API_KEY"],
    "engine": "google_ads_transparency_center",
    "advertiser_id": "AR15974021587678527489",
    "region": "2840",
    "creative_format": creativeFormat
    }
    search = requests.get("https://serpapi.com/search", params=params)
    results = search.json()
    return results

available_formats = ["text", "image", "video"]
for format in available_formats:
    print(getAdsByCreativeFormat(format))

Playground Example for getting only Video Ads for an advertiser: https://serpapi.com/playground?engine=google_ads_transparency_center&advertiser_id=AR15974021587678527489&region=2840&creative_format=video

Implementing Pagination To Get Results On All Pages

The Google Ads Transparency Center response may include multiple pages of ads. To efficiently retrieve data and navigate through multiple pages, we can utilize the num and next_page_token parameters.

About the Parameters:

num: This parameter determines the maximum number of search results to be returned. The default is 40. You can maximize the results received per request by setting num to a higher value. 100 is the maximum you can set num to.

next_page_token: This parameter is used for paginating through search results, enabling you to retrieve the next set of results.

Here is how you can set up the pagination flow:

Initial Request: Execute an initial request with your parameters of interest without next_page_token.
Sequential Access Of Results On Following Pages: Fetch the next results page using the next_page_token from the current response.
Last Page: Implement a check for the existence of next_page_token. If it's not present, it indicates that this is the last page and there are no more pages to retrieve.

Let's look at an example where we can use pagination to get all the pages of ads for Nestle Australia Ltd (advertiser_id: AR15820237500506439681) present on Google Ads Transparency Center in United States (region ID: 2840), using Pagination.

import os
import json
import requests

def get_ads(next_page_token=None):
    params = {
        "api_key": os.environ["API_KEY"],
        "engine": "google_ads_transparency_center",
        "advertiser_id": "AR15820237500506439681",
        "region": "2840",
        "num": "50",
    }

    if next_page_token is not None:
        params["next_page_token"] = next_page_token

    search = requests.get("https://serpapi.com/search", params=params)
    response = search.json()

    print(json.dumps(response, indent=2))

    ad_creatives = response.get("ad_creatives", [])
    print(f"Ads retrieved: {len(ad_creatives)}")

    next_token = (
        response.get("serpapi_pagination", {})
        .get("next_page_token")
    )

    if next_token:
        get_ads(next_token)
    else:
        print("All pages retrieved")


get_ads()

The function getAds starts with the first page of results. Above, I have set num to 50, but you can change that to any number between 1 and 100. If next_page_token is present in the response, the function calls itself recursively with the next_page_token, and gets the next set of results. When there is no next_page_token, it indicates that all pages have been retrieved, and the recursive function prints the message “All pages retrieved“ and stops.

By retrieving all this data, you can analyze all the ads to understand brand strategy and ad campaigns.

Scrape Google Ads Transparency Center using Node.js

The same API works in Node.js. The results are identical to the Python examples above.

First, install the serpapi package:

npm install serpapi

Then save your API key in the SERPAPI_API_KEY environment variable, just like in the Python section.

Example using Advertiser ID

In this example, the code targets Amazon's advertising campaigns using its advertiser_id and region (2840 is USA), the same as the Python example above. Analyzing the output lets you gain insights into Amazon's advertising strategy, preferred ad formats, and campaign durations.

const { getJson } = require("serpapi");

const API_KEY = process.env.SERPAPI_API_KEY;
const amazonAdvertiserId = "AR12815412684405080065"; // Amazon's Advertiser ID

async function fetchAdsByAdvertiserId(advertiserId) {
  try {
    const response = await getJson({
      engine: "google_ads_transparency_center",
      api_key: API_KEY,
      advertiser_id: advertiserId,
      region: "2840",
    });

    // Here you can process the response as needed
    console.log(JSON.stringify(response, null, 2));
  } catch (error) {
    console.error("Error fetching ads: ", error);
  }
}

// Fetching ads by Amazon's Advertiser ID
fetchAdsByAdvertiserId(amazonAdvertiserId);

Example comparing Regions

In this example, we will retrieve Amazon's advertisements in the United States (2840) and Canada (2124) using the specific region codes.

const { getJson } = require("serpapi");

const API_KEY = process.env.SERPAPI_API_KEY;
const amazonAdvertiserId = "AR12815412684405080065"; // Amazon's Advertiser ID

async function fetchAmazonAdsByRegion(regionCode) {
  try {
    const response = await getJson({
      engine: "google_ads_transparency_center",
      api_key: API_KEY,
      advertiser_id: amazonAdvertiserId,
      region: regionCode,
    });
    const ads = response.ad_creatives || [];
    console.log(`Amazon's Ads in region ${regionCode}: ${ads.length} ads on the first page`);
  } catch (error) {
    console.error("Error: ", error);
  }
}

// Fetching ads for Amazon in the United States (2840) and Canada (2124)
fetchAmazonAdsByRegion("2840"); // United States
fetchAmazonAdsByRegion("2124"); // Canada

You can use the data from these requests to compare Amazon's advertising content, format, and frequency in the United States versus Canada. It can provide insights into how Amazon adapts its advertising to resonate with the cultural and consumer preferences specific to each region.

Example with Pagination

The response from Google Ads Transparency Center can contain thousands of ads. Here, we get the ads for Nestle Australia Ltd (advertiser_id: AR15820237500506439681) in the United States (region ID: 2840) page by page with num and next_page_token, the same as the Python pagination example. The loop stops after maxPages and saves everything to ads.json.

const { getJson } = require("serpapi");
const fs = require("fs");

const API_KEY = process.env.SERPAPI_API_KEY;
const nestleAdvertiserId = "AR15820237500506439681"; // Nestle Australia Ltd's Advertiser ID
const maxPages = 5; // each page uses one search credit

async function fetchAllAds() {
  const allAds = [];
  const params = {
    engine: "google_ads_transparency_center",
    api_key: API_KEY,
    advertiser_id: nestleAdvertiserId,
    region: "2840",
    num: 50,
  };

  try {
    for (let page = 1; page <= maxPages; page++) {
      const response = await getJson(params);
      const ads = response.ad_creatives || [];
      allAds.push(...ads);
      console.log(`Page ${page}: ${ads.length} ads`);

      // Check for next page
      const nextToken = response.serpapi_pagination?.next_page_token;
      if (!nextToken) {
        console.log("All pages retrieved");
        break;
      }
      params.next_page_token = nextToken;
    }
  } catch (error) {
    console.error("Error: ", error);
  }

  fs.writeFileSync("ads.json", JSON.stringify(allAds, null, 2));
  console.log(`Saved ${allAds.length} ads to ads.json`);
}

fetchAllAds();

By retrieving all this data, you can analyze all the ads to understand brand strategy and ad campaigns.

Scrape Ad Details from Google Ads Transparency Center

The Google Ads Transparency Center API returns a list of ads with a preview image and when each ad was shown. To see what an ad actually says, open its details page. That page shows the headline, ad text, call to action, sitelinks, destination link, and every region where the ad ran.

Ad details page on Google Ads Transparency Center

Our Google Ads Transparency Center Ad Details API scrapes this page for you.

Parts of the API Request

advertiser_id: [Required] The Google Advertiser ID. It's the advertiser_id field in the Google Ads Transparency Center API results.
creative_id: [Required] The Google Creative ID. It's the ad_creative_id field in the Google Ads Transparency Center API results.
region: [Optional] The region code, same as above.
engine: [Required] Set to google_ads_transparency_center_ad_details.

💡
The Ad Details API needs both advertiser_id and creative_id in every request. Both come from each ad in the ad_creatives list: use its advertiser_id field, and pass its ad_creative_id field as creative_id.

Scrape Ad Details using Python

First, get a list of ads by following the Example using Advertiser ID above. Its response holds Amazon's ads in the US. This example takes the first 5 ads from that response, fetches the details of each one, and saves them to a CSV file. It also reuses the imports and SERPAPI_API_KEY from that example.

import csv

# `response` comes from the "Example using Advertiser ID" above
ad_creatives = response.get("ad_creatives", [])

# Get the details of each ad (one search credit per ad)
rows = []
for ad in ad_creatives[:5]:
    details_params = {
        "api_key": SERPAPI_API_KEY,
        "engine": "google_ads_transparency_center_ad_details",
        "advertiser_id": ad["advertiser_id"],
        "creative_id": ad["ad_creative_id"],
        "region": "2840",
    }
    details = requests.get("https://serpapi.com/search", params=details_params).json()

    info = details.get("search_information", {})
    regions = ", ".join(r.get("region_name", "") for r in info.get("regions", []))

    for creative in details.get("ad_creatives", []):
        row = {
            "creative_id": ad["ad_creative_id"],
            "format": info.get("format"),
            "headline": creative.get("headline") or creative.get("title"),
            "snippet": creative.get("snippet"),
            "call_to_action": creative.get("call_to_action"),
            "link": creative.get("link") or creative.get("visible_link"),
            "image": creative.get("image"),
            "regions": regions,
        }
        rows.append(row)
        print(row)

with open("ad_details.csv", "w", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=["creative_id", "format", "headline", "snippet", "call_to_action", "link", "image", "regions"])
    writer.writeheader()
    writer.writerows(rows)

print(f"Saved {len(rows)} ad variations to ad_details.csv")

One ad can have several variations, so the CSV can have more rows than ads. In Node.js, pass the same parameters to getJson.

Here is a shortened response for a text ad:

{
  "search_parameters": {
    "engine": "google_ads_transparency_center_ad_details",
    "advertiser_id": "AR12039459359856525313",
    "creative_id": "CR11382217505440268289"
  },
  "search_information": {
    "format": "text",
    "last_shown": 1755907200,
    "region_name": "anywhere",
    "more_ads_by_advertiser": "https://adstransparency.google.com/advertiser/AR12039459359856525313",
    "regions": [
      {
        "region": 2276,
        "region_name": "Germany",
        "first_shown": 1703376000,
        "last_shown": 1755561600
      },
      ...
    ]
  },
  "ad_creatives": [
    {
      "title": "Spaceship",
      "headline": "Spaceship.com Official Website - Connect Your Digital World",
      "snippet": "Propel your business into the digital frontier with Spaceship's cutting-edge web services...",
      "visible_link": "www.spaceship.com/",
      "sitelink_texts": [
        "Free Domain Privacy",
        "Domain Name Registration",
        "Domain Price List"
      ]
    },
    ...
  ]
}

Image and video ads return fields like image, call_to_action, video_link, and video_duration instead. Some ads come back as a single rendered image, so only the image field is available. You can find the full list of fields in the Ad Details API documentation.

With the ad details, you can compare the exact copy, offers, and landing pages your competitors use in each region.

Conclusion

You can scale your ad research using SerpApi APIs: Google Ads API and Google Ads Transparency Center API, in Python, Node.js, or any other language. When you need the full copy and regions of a specific ad, use the Google Ads Transparency Center Ad Details API.

As digital advertising becomes more prevalent and important, Google Ads Transparency Center API becomes a vital tool for staying competitive. Companies can use data from it and influence decision-making, shape strategies and identify impactful advertising methods.

I hope you found this tutorial helpful. If you have any questions, don't hesitate to reach out to me at contact@serpapi.com.

Documentation

SerpApi Unveils Google Ads Transparency Center API: Empowering Developers to Harness Ads Insights
SerpApi, a trailblazer in scraping serp results and data extraction solutions, is thrilled to announce the launch of the Google Ads Transparency Center API. This cutting-edge API is designed to provide software engineers and developers with unparalleled access to vital insights, enabling them to dive deep into published Google Ads.
Monitoring Competitors’ Google Ads
Google Ads Transparency Center is a search engine for ads that are published through Google. The move on Google on this is awesome for transparency on the internet. Google Ads Transparency Center gives the power to the users to block or report any ads for valid reasons. For marketers, it
How to easily scrape Google Ads Transparency Political Advertisement
Political Advertising have become necessary nowadays, and not utilizing it can mean losing elections, but how to efficiently discover and track what's being published and what's relevant to create counter strategies? With SerpApi, leveraging all this information becomes extremely easy.