📅 The Data Stack Show Live: The Future of Streaming Data

Register Now
By Rudderstack Team

How to load data from Google AdWords to Redshift

This post will help you sync your Google AdWords data to Amazon Redshift. By doing this, you will perform advanced analytics on a system designed for this kind of data, like Amazon Redshift. Alternatively, you can simplify the process of syncing data from Google AdWords to Amazon Redshift by using RudderStack, where RudderStack will handle the whole process, and you can focus on what matters - the analysis of your data.

Extract your data from Google AdWords

The AdWords API allows applications to interact directly with the AdWords platform. You can build applications to more efficiently manage large or complex AdWords accounts and campaigns. Contrary to the rest of the APIs that we have covered in this series of posts, the Google AdWords API is implemented only using the SOAP protocol, and it doesn’t offer a RESTful web implementation.

Nevertheless, they offer several client libraries that you can use for your language or framework of choice. They officially support clients in the following languages:

  • Java
  • .Net
  • PHP
  • PERL
  • Python
  • Ruby

The AdWords API is a complex product that exposes a lot of functionality to the user, ranging from reporting to do the bidding and programmatic advertisement. As the scope of this post is the extraction of data from it, with the aim of loading the data to a data warehouse for further analysis, we’ll focus only on that part of the Google AdWords API.

There are many ways of interacting with the data that AdWords API gathers. One way is to link your Google Analytics and AdWords accounts and actually enrich the data of your analytics with data coming from AdWords. If you have the luxury to afford a Google analytics premium account, the other possible way is to load your data directly to Google BigQuery. From there, you can either do your analysis from BigQuery or export your data to another data warehouse.

We’ll assume that you do not have a Google Analytics premium account. To be honest, if you had, you wouldn’t be looking at this post anyway, but you still want to extract data and load it to your own data warehouse solution. To do that, we’ll utilize the Report related functionality of the AdWords API. The API supports a huge number of reports that you can request, and it is possible to change the granularity of your results by passing specific parameters. Defining what kind of data you want to get back as part of your report can be done in two different ways.

  1. Using an XML-based report definition.
  2. Using an AWQL-based report definition.

If you want to use an XML-based report definition you have to include a parameter named __rdxml that will contain an XML serialized definition of the report you want to retrieve.

<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201509">
<selector>
<fields>CampaignId</fields>
<fields>Id</fields>
<fields>Impressions</fields>
<fields>Clicks</fields>
<fields>Cost</fields>
<predicates>
<field>Status</field>
<operator>IN</operator>
<values>ENABLED</values>
<values>PAUSED</values>
</predicates>
</selector>
<reportName>Custom Adgroup Performance Report</reportName>
<reportType>ADGROUP_PERFORMANCE_REPORT</reportType>
<dateRangeType>LAST_7_DAYS</dateRangeType>
<downloadFormat>CSV</downloadFormat>
</reportDefinition>

AWQL is a SQL-like language for performing queries against most common AdWords API services. Any service with a query method is supported; queryable fields for each service are listed here.

As a comparison you can see the difference between using XML and AWQL below:

XML

<serviceSelector>
<fields>Id</fields>
<fields>Name</fields>
<predicates>
<field>Status</field>
<operator>EQUALS</operator>