Google Ads script can be really helpful in automating your work and decreasing the load of manual work. These Ads scripts can also be used by amateurs if the right way of implementation and execution is known. In this step by step guide, you will be able to run Google Ads script for analyzing landing pages speed on the mobile device in your Google ads account.
Page Contents
1. Google Ads Script for Mobile Landing Page Speed Insights
Follow the steps below in order to save and run the script
- Login to your google ads account.
- Click on “Tools”
- Under “Bulk Actions”, click on “Scripts”
- It will open up a new page.
- Click on “+” sign to add a new script.
- There will be default main function (), remove it and remove every other code if you see. Make this page like a blank canvas
- Go to this URL and copy the whole source code from here: https://developers.google.com/google-ads/scripts/docs/solutions/mobile-pagespeed#source-code
- Now, Paste the script’s source code from the previous step
- Here is how your screen will probably look like
I have marked all the important fields in the above interface. You need to perform the following steps
- Name your script at the top
- Authorize your script by clicking on it and giving permission to access Google account on your behalf
- and, finally, save this script.
- Previewing at this stage might not work because we have not replaced some of the variables in the script with our values. It will be covered in the next section
2. Generate PageSpeed Insights API Key for your account
- On the same Scripts page in Google Ads as above, click Advanced APIs as shown below.
- At the bottom of the dialog that appears, click the Google API Console.
- Clicking it will open up a pop-up box.
- The popup box does not have all the options listed on it. So, we need to go to the developer console for different APIs by clicking on the link as shown in the red box
- Clicking on the link will take you to the APIs & Services page.
- Here, if you have for the first time, then you need to enable APIs and services by clicking on that button as shown below
- Clicking on that will open up the APIs library
- Find and click the PageSpeed Insights API link.
- On the following screen click Enable.
- In the left navigation, click Credentials
- Click on Create credentials on the main screen
- Create an API Key
- The API key is created. Click Restrict Key.
- Save it and copy the API Key
2.1 Replace parameters in the script
- There are two parameters that you need to replace in the script that you saved on the Google ads interface as shown below. Those parameters are:
- EMAIL_RECIPIENTS
- API_KEY
- Update the above fields
- Keep these updated fields within single quotation marks (”), that’s important.
- Save the script again
- If you want to add more than one email address, then just add another one separated by a comma.
3. Run Script for Mobile Landing Page Speed Insights
- You can either run your script from the script interface or from the main script interface. I prefer to run it from the main script interface
- To go to the main Scripts interface, click on the interface on the left panel as shown below
- It will open the main script interface where you can see all the scripts that you have made including the current one
- Under the “Actions” column, click on the drop-down button near “Options”
- You see the option to run, duplicate, disable, etc. Just “Run it”
- After running or during the run, the status of the script will keep on changing. It will look something like this: (In the screenshot, it’s a different script but all run the same way)
- Once the run is complete, you will see the status as finished successfully.
- Now, under the results, click on the log statements and it will show you the log
- At the bottom of the log, you will see a spreadsheet URL where all the logs will be there
- This URL is the same as the spreadsheet URL that you feed in the script at the beginning
- The script log looks like this, as shown below:
3.1 How this Script works?
The script examines URLs from the account – from Ads, Keywords and Sitelinks – using mobile final URLs if available, but defaulting to standard URLs otherwise. The first stage of the process is to build up a dictionary of as many URLs as time will allow.
Once this has completed, the script looks to identify URLs that are as different as possible – it is possible to imagine the scenario where a large number of URLs in an account return very similar pages. For example:
- http://www.example.com/product?id=123 and http://www.example.com/product?id=456
very probably return pages created from the same template. To this end, the difference is classified as follows:
- Most different – hosts are different – e.g. http://www.example.com/path and http://www.test.com/path.
- More different – hosts are the same, but paths differ – e.g. http://www.example.com/shop and http://www.example.com/blog.
- Least different – hosts and paths the same, parameters differ – e.g. http://www.example.com/shop?product=1 and http://www.example.com/shop?product=2.
A smaller subset of URLs – with the aim of being as different as possible by the above classification – are then selected and retrieved via the PageSpeed Insights API. The results are presented in a Google Spreadsheet, which is sent by email.
3.2 Setup the script frequency
- You can set the frequency of the script based on the fact that how frequent you make changes to your landing pages
- If you make changes on a daily basis, then set it to daily. Otherwise, you can also set it to weekly or other time frames such as monthly.
- The option to set frequency comes in the main Script window under frequency
Similarly, you can set up other scripts to automate your work. Otherwise, you should also try Google ads automated rules to automate your work.
4. Analyze Mobile Landing Page Speed Insights
- Once the Google Ads script for Mobile landing page speed insights has finished running, it will send you an email with a link to a Google sheet to the email ID you entered in step 2.1 of this article.
- Note that the initial run might take some time to send you the result. I would advise you to wait for around 15 minutes to half an hour to get the mobile landing page speed insights.
- Here is a screenshot of the report:
4.1 Reading the page speed insight analysis
The page speed insight will have four coloring codings. Green one is the best and red ones being the worst. You should start optimizing your landing pages with the red cells reports above. For example, in my case, it is mostly “optimize images” column followed by “Reduce Server Response time” need the most attention.
Here is a list of the items that this script reports for your page insights. I am also going to add their uses and priorities to be considered from user experience and landing page design:
- Speed
- Usability
- Avoid landing page redirects – High priority
- Avoid plugins
- Configure the viewport – For a better mobile landing page experience
- Enable compression
- Leverage browser caching – For a better experience for remarketing visitors
- Reduce server response time
- Minify CSS
- Minify HTML
- Minify JavaScript
- Eliminate render-blocking JavaScript and CSS in above-the-fold content – To reduce bounce rate
- Optimize images – High priority
- Prioritize visible content – To reduce landing page bounce rate
- Size content to Viewport – For a better mobile landing page experience
- Size tap targets appropriately – High priority for a conversion
- Use legible font sizes – High priority for a conversion or brand consideration
This whole process of running the script and finding out the mobile page speed score is recommended when you have hundreds or at least tens of landing pages in multiple campaigns. You can also avoid this whole procedure and use this online tool by Google for page speed insight. However, the whole procedure is manual here and you should consider automating if you feel like your campaigns are going to scale.
Hi,
For step 2. Generate PageSpeed Insights API Key,
“At the bottom of the dialog that appears, click the Google API Console.”
I don’t have that link in the dialog appear, only tick boxes. Has the UI changed? Or I missed something.
Thanks