First lets walk through what’s happening with the code. The first two variables yesterday and thirtydays will take the current system date and format it for Adwords. It will give us the dates from 30 days ago and yesterday’s date.

Second, the variable body constructs our satement that we’ll use to request Adwords data. Here we’re asking for Keywords Performance Report data for Search Networks for the past thirty days. We’ll get the following items in return:

Campaign Name

Ad Group Name

Criteria (Keyword)

Keyword Match Type (Broad, Phrase, Exact)

Quality Score

Impressions

Clicks

Click Through Rate (Clicks divided by Impressions)

Conversions

Average Cost Per Click (Clicks divided by Cost)

Cost

Date

Here the date variable, although last is still important. When we call the AdWords API, we’ll get all of the results for each day in the call. That’s great!

Third, we are going to save the call with getData() to a data frame called data. Once the results have been returned, we can begin our analysis.

Quality Score

To begin with, let’s run summary(data). This will gives us a summary of our data frame. One of the most important factors with keywords are the Quality Score of your keywords. The higher your Quality Score, the lower your CPC.

Let’s breakout the performance using dplyr, grouping by Quality Score and counting keywords:

We can see that there are 21 keywords with a Quality Score lower than six. Depending on the goals and needs of your campaigns, you may want to save these for later to pause or rewrite the ads associated with the keywords. You can do that using:

keywordsToChange <- data %>%
filter(Qualityscore < 6)

The quickest win that you get with your account is to increase the quality score. There are at least three main factors that affect your quality score:

Expected Click-Through Rate

Ad Relevance

Landing Page Experience

You can also add the following variables to your body request if you’d like to see them: SearchPredictedCtr, CreativeQualityScore and PostClickQualityScore.

Linear Regression

One of the quickest assumptions that people make about Adwords is that increasing your spend or your cost per click will automatically increase the number of conversions that you’ll recieve for that keyword.

To test that assumption, let’s build a linear regression model which can be done with lm(data$Conversions ~ data$CPC) and we can look at the full summary with summary(lm(data$Conversions ~ data$CPC))