Programmatic SEO: How I got on top of Google with WordPress, Elementor, and a bit of Python

  • 14 min read
I began learning Python in early 2023 and by spring, I was on the lookout for challenges to apply my new skills.

This quest for knowledge coincided with my growing interest in Programmatic SEO. It sparked an idea: what if I could write a script to automate the replacement of placeholders with variable text, links, and images?
I decided to focus on SEO Services for my test and compiled a list of the top 100+ cities in Romania, based on population, where I aimed to improve my search rankings.

The first challenge I encountered was page styling in WordPress. I realised that I need Elementor to align the pages to my site design, which meant manipulating text, links, and images within a more complex code structure.

I developed a Python script that I used to generate over 100 pages. Some of these pages achieved top positions on Google within a couple of months.

What is Programmatic SEO?

Programmatic SEO is a practice that uses automated tools or programming languages that allow automation to publish unique, high-quality pages or posts at scale using a predefined template and a database.

The primary goal of programmatic SEO is to improve a website’s discoverability in search engines by targeting a multitude of low-competition keywords, thereby increasing organic traffic and search engine rankings for those keywords.

This allows website owners to rapidly produce a large number of pages or posts optimised for related keywords.

In most cases, keywords used in Programmatic SEO have a base form + a modifier:
Programmatic SEO: base form keyword + modifier
The base word is the fixed part of the keyword. The modifier varies, as shown above. And I think you understand where I’m going with this explanation.

Programmatic SEO uses such terms where only one part of the long tail keyword changes to create a multitude of pages or posts. These pages share a common template, but specific content varies based on the keyword’s changing part, the modifier. This information normally comes from a database, and the process of publishing pages using the database data is automatic.

Ryan Law also provides a beginner-friendly explanation on Ahrefs’s blog. Check it out!

Pros and Cons for Programmatic SEO

Ok, so why doesn’t everyone use Programmatic SEO? Here are a few pros and cons for this practice.
Programmatic SEO is not a magic solution and may not be effective in all cases, especially if you can’t produce relevant and helpful content. Additionally, creating lots of pages also means you have to keep them all updated, which can get overwhelming.

Good examples of programmatic SEO

e.g. 1

Zapier

Zapier is a web automation tool used to connect over 6000 web apps and services. They are one of the pioneers of programmatic SEO. By analyzing the keywords potential customers search for, Zapier has created hundreds of thousands of programmatic pages that are user-friendly and precisely optimized for search engines.

These pages are designed to rank for integrations between two applications, such as ‘connect WordPress to Mailchimp’. In this case, the base form is ‘connect [app] to [app]’, where ‘[app]’ is the modifier.
Zapier - Programmatic- SEO page example
Zapier is the most famous case of Programmatic SEO and many have already thoroughly detailed how they did it. Here are some noteworthy examples:
e.g. 2

Airbnb

Another great example that is widely used in articles on this topic is Airbnb.
For those who have lived in a cave until now, Airbnb is a platform where users create listings, offering places for guests to stay or enabling hosts to rent out their space.

Airbnb leveraged Programmatic SEO to massively scale their online presence by automatically generating location-based listing pages. They focus on searches such as ‘[city_name] vacantion rental’, the name of the city being the modifier in their case.
Airbnb - Programmatic SEO search example
This strategy significantly increased their visibility for a wide array of location-specific search queries, driving more traffic to their site.

Omnius Agency from the UK has produced a comprehensive case study on Airbnb’s programmatic SEO strategy:
e.g. 3

Userpilot

Userpilot helps product teams deliver personalized in-app experiences to increase growth metrics at every stage of the user journey. All this without the need for programming experience.

They needed three years to reach 25,000 monthly visitors, but reached 100,000 in just 10 months by using Programmatic SEO techniques.
Userpilot - scaled to 100K visitors with Programmatic SEO
Source: seo.thefxck.com
Ben Goodey, a UK SEO strategist and founder of the How the F*CK website, has documented Userpilot’s case very well following a discussion with Emilia Korczyńska, their Head of Marketing.
You can read the first part of the case study for free if you sign up with your email address on the How the F*ck platform. However, you need to pay $17 to get full access to the case studies on Ben Goodey’s website, including part two of this one.
Or you can listen to the discussion between Ben and Emilia in the podcast below:

e.g. 4

Garden Auntie Blog

While the examples above are of giant platforms, this is a lighter example, meant to highlight that anyone can start working with Programmatic SEO.

Gardenauntie.com is a gardening blog made by Allison Seboldt, offering guides, tips, and personal experiences to help readers grow their own food at home, even in small spaces.

Allison began experimenting with Programmatic SEO as a digital marketing novice, attracted by the potential to automate content creation from data to target low-volume, long-tail keywords. She developed a system of templates to generate content quickly, to increase website traffic through highly targeted, data-driven SEO strategies. She targeted searches like ‘How to Grow [name_of_plant]’ where the plant’s name is the modifier.
Garden Auntie - Programmatic SEO posts example
I discovered Allison when I started working on a platform to collect all the functionality of the code I created in my Programmatic SEO endeavor. Searching for similar platforms I came across PageFactory, the platform Allison created in a similar effort to mine.

Read more about Allison’s experiment on her blog. She also offers a Free Programmatic SEO Course that details the subject and gives an introduction to her platform.
As you’ve already figured out from the examples above, programmatic SEO can be successfully applied if you target searches like:

How I indexed over 100 pages in Google

I began by selecting a topic. As you’ve seen, not all subjects suit this method. Considering I already had the ‘SEO Services’ page on my site, it seemed like a good starting point.

I decided my programmatic pages would be named ‘SEO Services + [Name_of_City]’. Having an existing page on this topic indexed on Google.ro should simplify the process of indexing local pages on the same matter. This approach seemed more effective than venturing into completely new topics.

*Note that all the content in the screenshots below has been translated from Romanian to English for this case study.
step 1

Research

I began the process as I do with any website or landing page development: with meticulous research. First, I identified the top 8 sites appearing in searches for ‘SEO services + [name of a large city in Romania]’. Next, I reviewed a few international sites that show up for searches in big cities.

After analyzing these sites, I noted down the sections my competitors have or lack. I plan to tick them off as I implement them on my landingpage.
Programmatic SEO page wireframe - What sections do I need?
From this list, I implemented the most relevant sections. I didn’t include a case study because the page was already long enough. Also, I decided against adding a WhatsApp widget because I didn’t want to be contacted there.
step 2

Wireframing

I quickly learned that using Elementor was necessary to integrate the pages into my website’s design. This made the process more complex. I realized the solution was to design pages with variable names first. Then, I replaced them with content in the generated Elementor code.
Programmatic SEO - Page wireframe with variables
Programmatic SEO - Local pages Excel file example
Programmatic SEO - Elementor code with variables
Programmatic SEO - Page final result
In total, I had 22 variables that I replaced with text. For each text, I prepared 4 variations which I randomly distributed in my Excel document, aiming to prevent duplicate content.

Moreover, leveraging the GPT for Sheets and Docs extension, I generated location-specific text like this:
Preparing an initial SEO Strategy takes about as long as walk from Victory Square to University Square and back, approximately 30 to 40 minutes. That’s roughly the time I need to respond to a Quotation Request.
Here, ‘University Square’ and ‘Victory Square’ represent real locations in Bucharest. This way I made sure I had unique content customized by location.

You can check all the pages here (in Romanian).
step 3

Python code

First, you need to install Python on your computer. You can do this by downloading the latest version of Python from the official website:
Open the command prompt (Windows key + R, then type CMD). Use this command to install the OpenPyXL library for Excel file handling:
pip install openpyxl 
Once the installation is over, your Command Prompt console should look like this:
Install OpenPyXL library on your computer
Following this, create a designated folder for your project. I named mine ‘Programmatic SEO Project’ and placed it on my Desktop.

Inside this folder, create a new file named ‘programmatic_seo_automation.py’. Here’s where you’ll insert the Python code:
import openpyxl

# Define the paths of your Programmatic SEO project:
template_file_path = 'C:\\Users\\Bogdan\\Desktop\\Programmatic SEO Project\\elementor_code.txt'  # Specify the path to the file containing the Elementor code
input_file_path = 'C:\\Users\\Bogdan\\Desktop\\Programmatic SEO Project\\variables_and_content.xlsx'  # Specify the path to the Excel file (where you defined variables and content)
output_directory = 'C:\\Users\\Bogdan\\Desktop\\Programmatic SEO Project\\Output\\'  # Specify the path to the folder where the new templates will be created

# Enter the names of your variables ( these must be identical to the column headings in your Excel document)
# The first variable will be used as a modifier in the template names created
variable_names = ['TOWN_NAME', 'WIKI_URL', 'PAGE_URL_SLUG', 'SLIDER_DESCRIPTION', 
                  'LINK_BUILDING_SERVICES', 'LOCAL_SEO_SERVICES', 'SEO_ON_PAGE_SERVICES', 
                  'SEO_CONTENT_SERVICES']  # Enter your variables between single quotes and use a comma to separate them


# DO NOT edit the code below
def replace_variables(template, **kwargs):
    for key, value in kwargs.items():
        template = template.replace(f'[{key.upper()}]', str(value))
    return template

with open(template_file_path, 'r', encoding='utf-8') as f:
    elementor_template = f.read()

wb = openpyxl.load_workbook(input_file_path)
ws = wb.active

file_count = 0

output_variable_name = variable_names[0]

for i, row in enumerate(ws.iter_rows(min_row=2, values_only=True), start=1):
    variables = dict(zip(variable_names, row[:len(variable_names)]))
    output_filename = f'{output_directory}elementor_code_{variables[output_variable_name]}.txt'
    output_content = replace_variables(elementor_template, **variables)
    with open(output_filename, 'w', encoding='utf-8') as f:
        f.write(output_content)
    file_count += 1
    print(f"{i}. File '{output_filename}' successfully generated.")

print("")
print("Finished.")
print(f"Total files generated: {file_count}")
input("Press Enter to exit...") 

You'll have to make a few adjustments to make it work. Let's delve into them:

  • Create a file named 'elementor_code.txt' in your project folder. Copy and paste the code from your Elementor page where variables are located. To copy, navigate to the bottom of the page, right-click in the 'Drag widget here' section, select 'Copy all content', and paste it into your .txt file.
How to copy code from Elementor page
  • Update the file path in the Python code to point to 'elementor_code.txt'.
  • Create an Excel file named 'variables_and_content.xlsx' in the same directory. Organize columns to correspond with each variable on your Elementor page.
  • Verify the Python code correctly references the Excel file path.
  • Establish a folder named 'Output' within your project folder.
  • Adjust the variables ['TOWN-NAME', 'WIKI_URL', etc.] in the Python code to match your own.

Important!

  • Variable names must be identical everywhere (in the page created with Elementor, in the Python code and in the Excel document). I have noted them everywhere with caps lock to make it easier to identify them.
  • The first variable in the list will be used in the name of the files produced as a modifier, in my case the files in the Output folder are named 'elementor_code_town_name'.

That’s it! Now, simply run the project to test its functionality. Open Command Prompt and navigate to your project folder using the following command:
cd C:\Users\Bogdan\Desktop\Programmatic SEO Project 
Then use the following command to run the Python script:
python programmatic_seo_automation.py 
Programmatic SEO - Run the Python code
Navigate to the Output folder and copy a template’s content. Paste it into an empty Elementor page using ‘Paste from other site’. Then press CTRL + V.

Or, consider using a plugin like WP All Import to automate page importing.

C’est fini!

Results

I published 138 pages, and a few weeks later, 92% of them were indexed.
How many pages have been indexed in Google
At the time of writing, 97% of the pages are indexed, with only 4 remaining unindexed. It’s worth noting that I did not attempt to request indexing manually.

Out of the published pages, 103 rank first for the search query ‘SEO Services + [city_name]’, while 19 appear in the second position on Google.ro.
Programmatic SEO pages keywords ranks
I didn’t secure a spot in the top 10 pages for Bucharest and Cluj-Napoca, Romania’s largest cities. However, my page ranks second for Iași, third largest, and fifth for both Constanța (4th town as size) and Timișoara (5th).

Many cities on my list are small, with only tens of thousands of residents. Romania has just 20 cities with over 100,000 residents. Hence, many main keywords have low traffic. But that’s okay because Programmatic SEO specifically targets positioning on many low-competition keywords, aiming for high cumulative traffic.

The pages don’t only appear for the main targeted keywords, thus accumulating 22.3K impressions and 132 clicks since their publication.
Google Search Console - Programmatic pages performance on the entire period
Of course you could argue that the CTR is too low and you’d be right. The pages can be improved, but that wasn’t the point of my experiment. I will probably delete them.

Now, do these pages satisfy the search intent of the users? Well… yes and no.

Yes, because we can argue that users might search for services in their area to ensure that the chosen provider is willing to offer them, as digital services can be performed remotely.

No, because users might search for a provider they want to meet in person, or who is in their proximity.

Risks

Programmatic SEO is an emerging technique that isn’t as widely discussed as other SEO methods. Its use is often kept quiet due to prevailing uncertainties.

Uncertainties that also result from the fact that Google publicly criticizes quantitative and AI-generated content, enforcing measures against spam and thin content. And Google is right because, despite its time-saving benefits, many users neglect thorough research and solid database creation before content generation, which results in penalties.

At the time of writing, Google had published an article on its blog, much debated in the SEO community, which I recommend you read:
Anyone who publishes a large number of very similar pages runs the risk of creating thin content (content that provides little or no value to the end user). Like any other type of content, programmatic content must satisfy the user’s intent.

Leave a Reply

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