How to easily scrape Google Ads Transparency Political Advertisement

Introduction

Political Advertisement is very important, and they are always present in several media, especially during elections season.
Google Ads allows the creation of Political Advertisement in many platforms, such as Google Search, Google Maps, Google Play, Google Shopping, Youtube and websites that participate in the Google AdSense program.
All advertisement made through Google Ads can be analyzed using the Google Ads Transparency Center. What is more, when it comes to Political Advertising specifically, Google offers even more information compared to regular ads, such as to how many people the advertisement was displayed, and how much money was invested in the campaign. In addition to that, there’s more information available for both Political Ads and regular Ads, like the Ad format, Platform where Ad is displayed, who is the Advertiser promoting the Ad, for how many days the Ad was displayed, the dates when the Ad was displayed, and more!

How are Political Ads different from regular Ads?

Google has a commitment for Ads transparency, and they support responsible Political advertising. For that reason, Google has extra requirements for advertisers who are posting Political Ads.
Because each country has different laws regarding what is allowed in Political Ads, advertisers creating Political Ads must specify at which country their Ads will be displayed. Additionally, they are required to be verified, and have more limited options for targeting. The only criteria that can be used to target election Ads are Geographic location, age, gender, and some contextual targeting options, such as Ad placements, topics, keywords agains sites, apps, pages and videos.

What information is available in Google Ads Transparency Center?

Political Ads sample on Google Ads Transparency Center website.

There’s a lot of relevant information about Political Ads that can be found on Google Ads Transparency Center listings, such as campaign impressions, budget and campaign length. Furthermore, when using SerpApi, there’s even more information that can be extracted from these listings, like Ad format, Advertiser Id and Ad Id.
SerpApi also empowers users to filter results by geographic location (list of all available locations), format (text, image & video), platform (Google Play, Google Maps, Google Search, Google Shopping & Youtube) and Ad text.

Now that we know the value we can get from scraping Google Ads Transparency Center, let’s see how we can use SerpApi to explore Political advertising on Google:

Setting Up a SerpApi Account

First, we need to create a SerpApi account. SerpApi has a Free tier that offers up to 100 searches per month.
Let’s head to the sign-up page to create an account. Provide a valid email and a valid phone number in order to access your account’s dashboard.

Signing up for a SerpApi account is very straightforward.
SerpApi Signup/Signin page where you can create an account by providing an unique email address and an unique phone number.

Exploring Political advertising on Google

Now that you have an account, you can sign in and use SerpApi’s Playground technology to explore Google Ads transparency Center political ads.

In order to get results related to Political Ads specifically, we must first set the parameter advertiser_id to the Id of a political advertiser, such as “Bloomberg L.P.“, whose Id is “AR07223290584121737217“, then it’s required to set the parameter political_ads to true and set the region parameter to the code related to the region of interest, for instance, we can set it to 2840 for results displayed in the United States.

We may also set filter parameters if we need more control over the results. We can use the parameter platform to get results of Ads that are being displayed in selected platforms, for example, we can set it to PLAY to get results only displayed on Google Play, or to MAPS for results on Google Maps, SEARCH for Google Search results, SHOPPING for Google Shopping results and YOUTUBE for Youtube results.

We may also use the filter parameter creative_format to text to only get text advertising results, to image for results of advertisement that have images, or to video to return advertisement that have videos attached to them.

Other filter parameters that can be very useful are the parameters start_date and end_date to filter results within a specific date range.

Google Political Advertisement results can have advertiser_id, advertiser, ad_creative_id, format, link, image, width, height, total_days_shown, first_shown, last_shown, minimum_views_count, maximum_views_count, minimum_budget_spent, maximum_budget_spent and details_link.

SerpApi's Playground is a great place to explore all Search Engines scraped by SerpApi.
Using SerpApi’s Playground technology makes it very easy to explore several Search Engines results, including from Google Ads Transparency Center

Integrating SerpApi with your application

Exploring SerpApi’s vast diversity of Search APIs using Playground is a lot of fun, but to get the most out of SerpApi’s services it’s best to use the results from Search Engines directly in your application programmatically.

In order to send requests to SerpApi, we will need your unique secret API key that can be copied right from your dashboard:

Find your secret and unique API key in SerpApi dashboard page.
Use your unique secret API key in your application to send requests to SerpApi programmatically.

Your API key is unique to you and you should never share it anywhere to avoid other people using your account, but in case you accidentally expose your API key, you can easily generate a new one from the Manage API key page (if you generate a new API key, don’t forget to update your application code with the newly generated API key).

Check out the documentation for SerpApi libraries based on the programming language you use:

To demonstrate how simple it is to use SerpApi in your code, here’s all you’d need to do to retrieve Google Political Ads results from your application using the Ruby language, as you can also see in SerpApi’s Google Ads Transparency Center API’s documentation page.

require 'google_search_results' 

params = {
  engine: "google_ads_transparency_center",
  advertiser_id: "AR17828074650563772417",
  region: "2840",
  political_ads: true,
  api_key: "YOUR_SECRET_API_KEY"
}

search = GoogleSearch.new(params)
ad_creatives = search.get_hash[:ad_creatives]

That’s all there is to it. Integrating SerpApi is extremely simple and straightforward. You can explore how to use all other Search Engine APIs offered by SerpApi at our documentation page, and play around with each of them using SerpApi’s Playground feature.

Have fun! 😃

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *