This Google Ads script uses GPT to summarize account performance

This Google Ads script uses GPT to summarize account performance

Last month, I shared my first Google Ads script that supports GPT. Identify missing RSA holders and suggest new variants.

This month, I wanted to push the limits of GPT a bit more and see if I could get it to write my next script for me. Spoiler alert: It worked! But I needed a little hand to get there. I will show you how I designed the message to get a satisfactory result.

The script I’m sharing uses OpenAI’s GPT to write a summary of account performance along with some suggestions on how to improve the performance of a Google Ads account.

Make PPC reports more descriptive

PPC reporting can be a tedious task. By nature, it’s also repetitive because customers and stakeholders expect the latest report in their inbox on a regular basis, be it weekly, monthly or, heaven forbid, even daily.

There are many great reporting tools out there (I work for one). While they can automate data extraction and visualization, generally making sense and telling a story with data requires the touch of a human. GPT excels at writing compelling stories, so it seemed like a good solution for my problem.

GPT and generative AI are experts at producing well-written text. Because large language models (LLMs) have read billions of words, they are very good at predicting how words go together in a way that makes for engaging reading.

But as compelling as they are, they’re not always true, and that’s a big problem when the goal is to share reliable reports with customers.

So I set out to find out if I could force GPT to be correct and a great storyteller about an ad account’s data.

The truth problem of GPT

A weakness of GPT is that its main strength is predicting the next word in a string. He is much less reliable when it comes to fact-checking and making sure what he says is correct.

Your training could have included dozens of blog posts on how to get more conversions in Google Ads.

Since these articles likely frequently mention tasks like checking budgets and managing CPA goals, GPT will likely include these things when generating tips related to getting more conversions.

But the details may be slightly off, such as whether an advertiser whose CPA is lower than the target CPA should increase or decrease their ad budget. GPT does not solve a problem analytically, but rather predicts the words to include in its hints.

Another problem is that GPT is still bad at math despite openAI’s work to address this known problem.

For example, if you provide data such as how many clicks and impressions a campaign has, it is not safe to assume that you will know how to determine the correct CTR based on this information. We all know it’s a simple formula: clicks/impressions = CTR.

Sometimes GPT will do just fine, but there’s no guarantee.

To avoid miscalculations, I decided it would be safer to do the math myself and provide the results to the indicator.

Instead of relying on GPT to correctly calculate metrics like CTR, conversion rate, etc., I provided the values ​​of these metrics in the request.

How to provide GPT with data about your company

The specific task I wanted to automate was to describe how an account’s performance changed last month compared to the previous month and include some optimization suggestions.

When I created this automation, I couldn’t jump right into the code. I had to manually create a working process before turning that process into an automation.

The first step was to experiment with GPT to determine what data it needed to stop making up facts and rely on the truth to craft its stories. This required giving it Google Ads data with the facts I wanted it to describe.

Fortunately, GPT can take a table as input and figure out how to interpret the different cells. So I created a campaign performance table and exported it as a CSV text file that could be copied and pasted into a GPT message.

Because I wanted GPT to comment on changes in performance between two date ranges, I initially entered two separate CSV strings, one for each period.

But two separate CSV strings use more records than the same data combined into a single CSV with separate columns for different date ranges.

So, to improve the automation a bit for working with larger accounts, I generated the combined CSV string.

With the actual data ready to be inserted into a request, I could then move on to designing the request to give me the best possible results.

Fast engineering

With real data to work with, I next had to tell GPT what to do with those facts. The message could be as simple as:

“Write a summary of the campaigns’ performance comparing the two periods.”

GPT is smart and figures out what the different periods are in the CSV data.

If you tend to focus too much on certain metrics that you’d like to de-prioritize, add more details to your request, such as:

“Do not include search lost ISs in summary.”

Next, I wanted you to include some optimization tips. To make the suggestions more reliable and more in line with my own management style, I loaded the message with some additional facts like these:

The target CPA is $20. Higher cost is bad, and lower cost is good. If lost IM search (budget) > 10% and CPA is lower than target, budget should be increased. if the CPA is above the target, the bids should be adjusted.

Then when he sent a very detailed message with CSV data, facts and a request about what to do with that data, GPT started giving solid answers.

With all the puzzle pieces in place, it was time to ask GPT to write the automation for me.

Get the daily search newsletter marketers trust.

Getting GPT to write ad scripts

The code for a Google Ads script to extract data from an account is not particularly complicated. It is part of almost any script and is very well documented.

So I crossed my fingers and asked GPT to write a script to extract the data for me with this prompt:

The answer felt like a good script, but one thing felt a little off. I was writing a GAQL query that included the two date ranges I wanted to compare in a single query. This should not work.

Incorrect output

So I asked GPT to try again, and although the implementation changed slightly, it again altered the date ranges in the GAQL query:

Incorrect output

At this point, I could have given up and fixed the code myself, but instead, I did some quick engineering.

What happens if my request confesses GPT?

I said it to:

“Get metrics for clicks, impressions, cost, CTR, average CPC, conversions, conversion rate and cost per conversion for the previous month and the month before that.

Could you be more clear and say that this should be done in two separate queries that will be merged later?

So I changed the message to include this new text:

“Get the metrics for clicks, impressions, cost, CTR, average CPC, conversions, conversion rate and cost per conversion. Get the report for two date ranges: last month and previous month. create a map where the key is the campaign name and include the statistics for the 2 date ranges.

This is much more accurate and the result was as follows:

Google Ads script

Now GPT was writing the correct code. After installing it in my Google Ads account, it immediately worked as expected and generated the required CSV data.

This was a good quick engineering lesson for me. If you’re hiring a new team member who’s never done PPC, you’ll probably need to be pretty specific in your instructions when asking for help. Same with GPT, accuracy is important!

In addition, it is still important to be an expert in the field. Someone who has never worked with GAQL reports or the Google Ads API might not know that you can’t get data from two date ranges in a single call. Without this knowledge, finding the error in the GPT response could be very difficult.

In short, when asking GPT to generate code, it’s helpful to write pseudocode instead of being too general and telling it just what outputs you expect. The more you tell the system how to get to that output, the more likely it is to write code that works.

With the code to extract CSV data working, I now needed some code to send that data to GPT to request a digest.

Using GPT in Google Ads scripts

To use GPT in a script, you need API access and an API token. You can sign up for this at OpenAI website. With this, you can write a simple function that calls the API with a request, gets the response, and prints it to the screen.

This code could be requested from GPT, but I already had it from last month’s RSA script, so I reused it.

Here is the code snippet for using GPT in Google Ads scripts

putting it together

Next, I put the two scripts above together. The first script gets the data I need for my request, and the second script sends that data as a request to GPT and captures the response, which is then displayed on the screen.

Grab a copy of the full code here and remember to add your own API key to get started:

Then you should experiment with the facts and prompt. The line of code where you enter the facts should include the details you want GPT to know, such as:

What is your goal? Whether a number above or below the target is good or bad. Information about your account optimization methodology (ie what you would recommend doing if the CPA is too high and impressions have decreased).

GPT will draw from the facts you have provided rather than make things up when summarizing performance.

You can also design the message to do things the way you want.

For example, you can ask GPT to include or exclude specific metrics in your summary, or tell it in what style to write, for example, conversational or business-oriented.

Note that this script uses the OpenAI API, which is no free So every time you run this, it will cost money.

I recommend running this script as needed and not putting it on an automated schedule.

Summary of PPC performance with GPT

GPT is great for writing, but can have trouble with fact correcting. That’s why it’s helpful to provide as many facts as possible in your directions.

Using a Google Ads script, account performance data can be automatically prepared in a format that works with GPT.

Use this script to provide GPT with data about your account and get a performance summary that can be shared with clients and stakeholders.

I encourage you to check it out and let me know what you think.

The views expressed in this article are those of the guest author and not necessarily Search Engine Land. Staff authors are listed here.

Source link

You May Also Like

About the Author: Ted Simmons

I follow and report the current news trends on Google news.

Leave a Reply

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