Categories
Articles

How to use Google Analytics & Google Tag Manager as SEO crawler

In these slides and my conference talk (from 2020), I’ll show you how to use GTM together with Universal Analytics as a SEO crawler.

The ideas shown in this talk are recyclable and modifiable also for GA4 – and of course also for other digital analytics tools like Matomo Analytics or Piwik PRO.

Using Google Tag Manager to Collect SEO Data

Click here to display content from YouTube.
Learn more in YouTube’s privacy policy.

In this presentation, I explore a method for collecting SEO data using Google Analytics, Google Tag Manager, and Javascript. The focus is on Universal Analytics, but the concepts I discuss can be applied to other analytics tools.

This version is created using Google’s NotebookLM.

Combining SEO and Analytics Data

As an SEO professional, I often use a variety of tools to collect data. These tools may include Ahrefs, Semrush, Search Metrics, Search Console, and Google Analytics. This data is often siloed, so I suggest combining SEO data with website traffic and user behavior data from Google Analytics. I recommend using Google Tag Manager and Javascript to send SEO data to Google Analytics. This method allows me to collect real-time data as users browse a website.

Setting up SEO Data Tracking

Here are the steps I outline for setting up SEO data tracking using Google Tag Manager:

  1. Add custom dimensions to Google Analytics.
    You can find these settings in the Admin section of Google Analytics, under Property Settings. Scroll to the bottom of the screen to find custom dimensions and custom metrics. I suggest creating 20 custom dimensions initially, using simple names like custom dim 1, 2, 3, etc. You can rename them to be more descriptive later. When setting up Google Tag Manager, you’ll need the index for each custom dimension.
  2. Implement Google Tag Manager variables.
    Use Javascript to extract the data you want from the HTML.
  3. Configure the Google Analytics settings variable.
    This will allow you to send the SEO data to the corresponding custom dimensions in Google Analytics.
  4. Test and publish the container.
  5. Wait for the data to become available in Google Analytics.
    This can take up to 24 hours.

Using Javascript to Collect SEO Data

I explain that you can use Javascript to collect any data available on the webpage, as long as it’s in the HTML. You need to own the website to analyze it using this method.

Here are some examples of the data you can collect using Javascript:

  • Document Language:
    Extract the document language using document.documentElement.lang. This information can be stored in Google Analytics as a custom dimension or a content grouping. I suggest using a content grouping to track document language because the free version of Google Analytics offers five extra content groupings, while you are limited to 20 custom dimensions.
  • Canonical URLs:
    Determine if the canonical URL matches the current page URL.
  • Meta Description Length:
    Calculate the length of the meta description.
  • Title Length:
    Obtain the title length using the global variable document.title.length.
  • Heading Analysis:
    Collect all the H1 headings on a page and their content length.
  • Content Length:
    Analyze the length of the main content by targeting the relevant HTML element (e.g., by using the class name “entry-content”). I use this method to analyze the length of blog posts to explore the relationship between blog post length, user behavior, and traffic.
  • Internal and External Link Count:
    Count the number of internal and external links on a page by examining the link hostnames.
  • Robots Meta Tag:
    Retrieve information from the robots meta tag and implement error handling for pages without a robots tag.

I also explain how to report on custom dimensions in Google Analytics. Use secondary dimensions to check your data, or create custom reports to look at all your custom dimensions. When creating a custom report, use page as a standard dimension and add up to four additional custom dimensions.

Advantages and Disadvantages

Advantages:

  • No need for additional SEO software.
  • Real-time data collection synced with user behavior data.

Disadvantages:

  • Some SEO details may be impossible to track using this method.
  • Data relies on website traffic; without traffic, you won’t collect any data.
  • Extra tags might slow down page load speed.

Conclusion

In this presentation, I offer a way to integrate SEO data into Google Analytics using Google Tag Manager and Javascript. By understanding how the HTML on your website is structured, you can use Javascript to collect SEO data and analyze its impact on user behavior.