Final month, I shared my first GPT-enabled Google Advertisements script. It identifies lacking RSA headlines and suggests new variants.
This month, I wished to push the boundaries of GPT slightly more durable and see if I might get it to put in writing my subsequent script for me. Spoiler alert: It labored! Nevertheless it wanted some handholding to get there. I’ll educate you ways I engineered the immediate to get a profitable outcome.
The script I’m sharing makes use of OpenAI’s GPT to put in writing an account efficiency abstract together with some solutions for the best way to enhance the efficiency of a Google Advertisements account.
Making PPC experiences extra descriptive
PPC reporting could be a tedious process. By nature, it’s additionally repetitive as a result of purchasers and stakeholders count on the newest report of their inbox usually – be it weekly, month-to-month, or, heaven forbid, even day by day.
There are many nice reporting instruments (I work for one). Whereas they will automate pulling within the knowledge and visualizing it, making sense of and telling a narrative with the info often nonetheless require a human’s contact. GPT excels at writing compelling tales, so it appeared like a great answer for my drawback.
GPT and generative AI are adept at producing well-written textual content. As a result of giant language fashions (LLMs) have learn billions of phrases, they’re superb at predicting the best way to put phrases collectively in a manner that makes for a compelling learn.
However as compelling as they could be, they’re not all the time true, and that’s an enormous drawback when the aim is to share reliable experiences with purchasers.
So I set out to determine if I might pressure GPT to be appropriate and a terrific storyteller in regards to the knowledge in an adverts account.
GPT’s reality drawback
A weak spot of GPT is that its core energy is predicting the subsequent phrase in a string. It’s a lot much less dependable in the case of fact-checking and guaranteeing what it says is appropriate.
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 in all probability continuously 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 could get the small print barely mistaken, 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 relatively predicting the phrases to incorporate in its recommendation.
One other drawback is that GPT stays dangerous at math regardless of openAI’s work to deal with this identified drawback.
For instance, if supplied with info 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 proper CTR from this data. Everyone knows it’s a easy system: 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 maths myself and supply the ends in the immediate.
Slightly than trusting GPT to calculate metrics like CTR, conversion charge, and many others., accurately, I supplied the values for these metrics within the immediate.
Find out how to present GPT with info about what you are promoting
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 solutions.
When creating this automation, I couldn’t bounce 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 knowledge it wanted so it could cease making up info and as an alternative depend on the reality for crafting its tales. This required giving it Google Advertisements knowledge with the info I wished it to explain.
Happily, GPT can take a desk as enter and work out the best way to interpret the varied cells. So I created a desk of marketing campaign efficiency and exported it as a CSV textual content file which could possibly 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 knowledge mixed right into a single CSV with separate columns for various date ranges.
So to make the automation barely higher at working with larger accounts, I generated the mixed CSV string.
With factual knowledge able to insert right into a immediate, I might then transfer on to engineer the immediate to provide me the very best outcomes attainable.
Immediate engineering
With factual knowledge to work with, I subsequent wanted to inform GPT what to do with these info. The immediate could possibly be so simple as:
- “Write a abstract of the campaigns’ efficiency evaluating the 2 durations.”
GPT is wise and figures out what the totally different durations within the CSV knowledge are.
If it tends to focus an excessive amount of on sure metrics you’d wish 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 solutions extra dependable and extra consistent with my very own administration type, I loaded the immediate with some further info like these:
- The goal CPA is $20. A price greater is dangerous, and a price decrease is nice.
- If the Search misplaced IS (funds) > 10% and the CPA is beneath the goal, the funds must be raised.
- if the CPA is above the goal, the bids must be adjusted.
Then when sending a really detailed immediate with CSV knowledge, info, and a request for what to do with this knowledge, GPT began giving strong solutions.
With all of the puzzle items in place, it was time to ask GPT to put in writing me the automation.
Get the day by day publication search entrepreneurs depend on.
Getting GPT to put in writing Advertisements scripts
The code for a Google Advertisements script to tug knowledge from an account isn’t notably difficult. It’s a part of nearly any script and really nicely documented.
So I crossed my fingers and requested GPT to put in writing a script to tug the info for me with this immediate:

The response seemed 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 speculated to work.

So I requested GPT to strive 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 might 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 informed it to:
- “Get the clicks, impressions, price, CTR, common CPC, conversions, conversion charge, and price per conversion metrics for the earlier month and the month earlier than that.”
Might I be clearer and inform it this must be completed in two separate queries that may be merged later?
So I modified the immediate to incorporate this new textual content:
- “Get the clicks, impressions, price, CTR, common CPC, conversions, conversion charge, and price per conversion metrics. Get the report for two date ranges: final month and the month earlier than that. construct a map the place the secret’s the marketing campaign title and it consists of the stats from the two date ranges.”
That is way more exact, and the outcome got here again as follows:

Now GPT was writing the proper code. After putting in it in my Google Advertisements account, it instantly labored as anticipated and generated the wanted CSV knowledge.
This was a great lesson in immediate engineering for me. In case you rent a brand new group member who’s by no means completed PPC, you in all probability have to be fairly exact in your directions while you ask for assist. It’s the identical with GPT, precision issues!
Additionally, it nonetheless issues to be a topic skilled. Somebody who’s by no means labored with GAQL or API experiences from Google Advertisements may not know that you may’t get knowledge for 2 date ranges in a single name. With out that data, discovering the error within the GPT response could possibly be very tough.
Backside line, when asking GPT to generate code, it’s useful to put in writing pseudo-code relatively than being too basic and solely telling it what outputs you count on. The extra you inform the system the best way to arrive at that output, the extra possible it’s going to write code that works.
With the code to tug CSV knowledge working, I now wanted some code to ship that knowledge 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 web site. With that, you possibly can write a easy perform that calls the API with a immediate, will get the response, and prints it on the display.
This code could possibly 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 info I want for my immediate, and the second script sends that knowledge as a immediate to GPT and captures the response, which is then rendered on display.
Seize a replica of the whole code right here and keep in mind so as to add your personal API key to start out utilizing it:
Then you need to experiment with the info and immediate. The road within the code the place you enter info ought to embody particulars you need GPT to know, corresponding to:
- What your goal is.
- Whether or not a quantity greater or decrease than the goal is nice or dangerous.
- Details about your account optimization methodology (i.e., what you’ll suggest doing if the CPA is simply too excessive and the impressions have decreased).
GPT will pull from the info you supplied relatively than making stuff up when it summarizes the efficiency.
You can too engineer the immediate to do issues the way in which you need.
For instance, you can ask GPT to incorporate or exclude specific metrics in its abstract or inform it what type to put in writing 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’s going to price cash.
I like to recommend working this script as wanted and never placing it on an automatic schedule.
Summarizing PPC efficiency with GPT
GPT is superb at writing however can have issues with factual correctness. That’s the reason offering as many info as attainable within the prompts is useful.
Through the use of a Google Advertisements script, info about account efficiency can mechanically be ready in a format that works with GPT.
Use this script to supply GPT with info about your account and get a efficiency abstract that may be shared with purchasers and stakeholders.
I encourage you to test it out and let me know what you assume.
Opinions expressed on this article are these of the visitor creator and never essentially Search Engine Land. Employees authors are listed right here.