This Google Ads script uses GPT to summarize account performance
Final month, I shared my first GPT-enabled Google Ads script. It identifies lacking RSA headlines and suggests new variants.
This month, I wished to push the bounds of GPT a little bit more durable and see if I may get it to write down my subsequent script for me. Spoiler alert: It labored! Nevertheless it wanted some handholding to get there. I’ll train you the way I engineered the immediate to get a profitable consequence.
The script I’m sharing makes use of OpenAI’s GPT to write down an account efficiency abstract together with some options for the best way to enhance the efficiency of a Google Advertisements account.
Making PPC reviews extra descriptive
PPC reporting could be a tedious process. By nature, it’s additionally repetitive as a result of shoppers and stakeholders anticipate the most recent report of their inbox often – be it weekly, month-to-month, or, heaven forbid, even every day.
There are many nice reporting instruments (I work for one). Whereas they will automate pulling within the information and visualizing it, making sense of and telling a narrative with the information normally nonetheless require a human’s contact. GPT excels at writing compelling tales, so it appeared like a great answer for my downside.
GPT and generative AI are adept at producing well-written textual content. As a result of large language models (LLMs) have learn billions of phrases, they’re excellent at predicting the best way to put phrases collectively in a approach that makes for a compelling learn.
However as compelling as they might be, they’re not at all times true, and that’s a giant downside when the objective is to share reliable reviews with shoppers.
So I set out to determine if I may drive GPT to be right and an important storyteller concerning the information in an advertisements account.
GPT’s fact downside
A weak spot of GPT is that its core power is predicting the following phrase in a string. It’s a lot much less dependable relating to fact-checking and making certain what it says is right.
Its coaching might need included dozens of weblog posts about the best way to get extra conversions in Google Advertisements.
As a result of these articles most likely incessantly point out duties like checking budgets and managing CPA targets, GPT will possible embody these issues when it generates recommendation associated to getting extra conversions.
However it might get the main points barely fallacious, like whether or not an advertiser whose CPA is decrease than the goal CPA ought to improve or lower their advert funds. GPT isn’t fixing an issue analytically however fairly predicting the phrases to incorporate in its recommendation.
One other downside is that GPT stays unhealthy at math regardless of openAI’s work to deal with this recognized downside.
For instance, if supplied with details like what number of clicks and impressions a marketing campaign has, it’s not secure to imagine that it’s going to know the best way to decide the right CTR from this data. Everyone knows it’s a easy method: clicks/impressions = CTR.
Typically GPT will get it proper, however there’s no assure.
To keep away from calculation errors, I made a decision it could be safer to do the mathematics myself and supply the ends in the immediate.
Reasonably than trusting GPT to calculate metrics like CTR, conversion price, and so on., accurately, I supplied the values for these metrics within the immediate.
Easy methods to present GPT with details about your enterprise
The precise process I wished to automate was describing how an account’s efficiency modified final month in comparison with the month earlier than and together with some optimization options.
When creating this automation, I couldn’t soar straight into the code. I needed to manually create a course of that labored earlier than turning that course of into an automation.
Step one was to experiment with GPT to find out what information it wanted so it could cease making up details and as an alternative depend on the reality for crafting its tales. This required giving it Google Advertisements information with the details I wished it to explain.
Happily, GPT can take a desk as enter and determine the best way to interpret the assorted cells. So I created a desk of marketing campaign efficiency and exported it as a CSV textual content file which might be copied and pasted right into a GPT immediate.
As a result of I wished GPT to touch upon the modifications in efficiency between two date ranges, I initially introduced in two separate CSV strings, one for every interval.
However two separate CSV strings use extra tokens than the identical information mixed right into a single CSV with separate columns for various date ranges.
So to make the automation barely higher at working with greater accounts, I generated the mixed CSV string.
With factual information able to insert right into a immediate, I may then transfer on to engineer the immediate to provide me the very best outcomes doable.
With factual information to work with, I subsequent wanted to inform GPT what to do with these details. The immediate might be so simple as:
- “Write a abstract of the campaigns’ efficiency evaluating the 2 durations.”
GPT is sensible and figures out what the totally different durations within the CSV information are.
If it tends to focus an excessive amount of on sure metrics you’d prefer to deprioritize, add extra element to the immediate, like:
- “Don’t embody Search Misplaced IS within the abstract.”
Subsequent, I wished it to incorporate some optimization suggestions. To make the options extra dependable and extra in keeping with my very own administration fashion, I loaded the immediate with some further details like these:
- The goal CPA is $20. A value increased is unhealthy, and a value decrease is sweet.
- If the Search misplaced IS (funds) > 10% and the CPA is beneath the goal, the funds needs to be raised.
- if the CPA is above the goal, the bids needs to be adjusted.
Then when sending a really detailed immediate with CSV information, details, and a request for what to do with this information, GPT began giving stable solutions.
With all of the puzzle items in place, it was time to ask GPT to write down me the automation.
Get the every day publication search entrepreneurs depend on.
Getting GPT to write down Advertisements scripts
The code for a Google Advertisements script to drag information from an account isn’t notably difficult. It’s a part of nearly any script and really effectively documented.
So I crossed my fingers and requested GPT to write down a script to drag the information for me with this immediate:
The response appeared like a great script, however one factor appeared a bit off. It was writing a GAQL question that included the 2 date ranges I wished to check in a single question. That isn’t imagined to work.
So I requested GPT to attempt once more, and whereas the implementation modified barely, it as soon as once more tousled the date ranges within the GAQL question:
At this level, I may have given up and glued the code myself, however as an alternative, I did some immediate engineering.
What if my immediate was complicated GPT?
I instructed it to:
- “Get the clicks, impressions, price, CTR, common CPC, conversions, conversion price, and value per conversion metrics for the earlier month and the month earlier than that.”
May I be clearer and inform it this needs to be performed in two separate queries that will be merged later?
So I modified the immediate to incorporate this new textual content:
- “Get the clicks, impressions, price, CTR, common CPC, conversions, conversion price, and value per conversion metrics. Get the report for two date ranges: final month and the month earlier than that. construct a map the place the hot button is the marketing campaign title and it contains the stats from the two date ranges.”
That is rather more exact, and the consequence got here again as follows:
Now GPT was writing the right code. After putting in it in my Google Advertisements account, it instantly labored as anticipated and generated the wanted CSV information.
This was a great lesson in immediate engineering for me. In case you rent a brand new crew member who’s by no means performed PPC, you most likely have to be fairly exact in your directions once you ask for assist. It’s the identical with GPT, precision issues!
Additionally, it nonetheless issues to be a topic professional. Somebody who’s by no means labored with GAQL or API reviews from Google Advertisements won’t know that you could’t get information for 2 date ranges in a single name. With out that data, discovering the error within the GPT response might be very troublesome.
Backside line, when asking GPT to generate code, it’s useful to write down pseudo-code fairly than being too basic and solely telling it what outputs you anticipate. The extra you inform the system the best way to arrive at that output, the extra possible it would write code that works.
With the code to drag CSV information working, I now wanted some code to ship that information to GPT to ask for a abstract.
Utilizing GPT in Google Advertisements scripts
To make use of GPT in a script, you want API entry and an API token. You’ll be able to join this on the OpenAI website. With that, you may write a easy perform that calls the API with a immediate, will get the response, and prints it on the display screen.
This code might be requested from GPT, however I already had it from final month’s RSA script so I simply reused that.
Right here’s the code snippet to make use of GPT in Google Advertisements scripts
Placing it collectively
Subsequent, I put the 2 scripts above collectively. The primary script will get the information I would like for my immediate, and the second script sends that information as a immediate to GPT and captures the response, which is then rendered on display screen.
Seize a duplicate of the whole code right here and keep in mind so as to add your individual API key to begin utilizing it:
Then it is best to experiment with the details and immediate. The road within the code the place you enter details ought to embody particulars you need GPT to know, corresponding to:
- What your goal is.
- Whether or not a quantity increased or decrease than the goal is sweet or unhealthy.
- Information about your account optimization methodology (i.e., what you’d suggest doing if the CPA is simply too excessive and the impressions have decreased).
GPT will pull from the details you supplied fairly than making stuff up when it summarizes the efficiency.
You too can engineer the immediate to do issues the way in which you need.
For instance, you possibly can ask GPT to incorporate or exclude explicit metrics in its abstract or inform it what fashion to write down in, e.g., conversational or business-oriented.
Keep in mind that this script makes use of the OpenAI API, which is not free. So each time you run this, it would price cash.
I like to recommend operating this script as wanted and never placing it on an automatic schedule.
Summarizing PPC efficiency with GPT
GPT is great at writing however can have issues with factual correctness. That’s the reason offering as many details as doable within the prompts is useful.
Through the use of a Google Advertisements script, details about account efficiency can mechanically be ready in a format that works with GPT.
Use this script to offer GPT with details about your account and get a efficiency abstract that may be shared with shoppers and stakeholders.
I encourage you to test it out and let me know what you suppose.
Opinions expressed on this article are these of the visitor creator and never essentially Search Engine Land. Workers authors are listed here.