Those who regularly set up PPC campaigns know firsthand how time-consuming the process of linking – or matching – a page address with a keyword phrase can be. For the purity of the experiment, we will understand by a multi-page site a truly MULTI-page site, consisting of at least hundreds of landing pages.
Many professionals want a tool that can help them cope with this task. The method described in this article does not require programming skills or advanced technical knowledge.
We will solve the problem of matching keywords and landing pages using a small script written in Python. To work with it, I recommend installing the Anaconda package with the Jupyter Notebook environment, since in addition to the core of the language, this package contains a whole set of external modules.
The mechanics of the script
The mechanism of the script is very simple. He takes a key phrase and runs through all the page descriptions, looking for the description, the words in which overlap as closely as possible with the words from the key phrase. A small schematic illustration below will help you understand how the script works with a small example. Note that the script does not work with word forms, that is, it works with exact word matches and is case insensitive.
Despite the simplicity of the idea underlying the mechanics of the script, the result of the work is quite adequate even by “human” standards.
The running time of the script is measured in seconds and minutes, but for the script to work successfully, you need to prepare. You will need:
List of key phrases for which you are selecting pages.
List of landing page addresses and their descriptions (product name, model, SKU, etc.)
To correctly concatenate a key phrase with a landing page, we need a list of words that would characterize this page. In the overwhelming majority of cases, the h1 heading and the SKU or product model will suffice if they are displayed in separate fields. As you can see from the example in the screenshot, “DIESEL LOADER TCM FD 115-3” is enclosed in the h1 tag, class b1c-name.
Such information can be downloaded by a technical specialist who maintains the site, usually the values of these fields are stored in a special database with product cards. Or you can parse the data yourself or order the parsing from a third-party specialist.
The work of the script is hard enough to be used by specialists with different levels of training.
Working out the script
Before starting work, you need to create a separate folder and place the file in it ppc_sci.url_matcher.py with a script (.py is a standard Python language file), which you can download from the link.
In the same working folder you need to place the file links.xlsx with two sheets:
sheet url_descriptionscontaining two columns: field Url with landing page addresses and field DESCRIPTION with a description of the pages:
sheet keywords with one column KEYWORD with key phrases:
In total, there should be two files in the folder before starting work:
Also, you must have the standard Anaconda package installed and the pandas and openpyxl modules preinstalled.
First, create a workbook .ipynb in the folder with prepared files.
Close the file before starting the script. links.xlsx… Enter the command in the cell of the workbook % run ppc_sci.url_matcher.py and press the button Run…
The appeared text “The sheet ‘keywords_url’ is written to the source file ‘links.xlsx’.” means the script ran successfully.
The result of the script will be placed on the newly created sheet. keywords_url in source file links.xlsx…
A little about performance
For the test, an array of 834 landing pages with their descriptions and 17125 key phrases was selected. On a medium-sized laptop, the average script run time was 49 seconds.
Some colleagues who try this script will think that some “magic” is happening, in fact, the script is quite primitive and fast enough for a person with average programming skills. If you have a desire to develop such scripts to automate workflows, enroll in the basic PPC-Scientist course.
Leave your questions about the script, as well as suggestions and ideas for new scripts in the comments to the article. All success in setting up