Optimizing SEO Through JavaScript and CDNs

I hope you enjoy this post!  To get expert ideas into how to grow your business faster online, click here.

Craig Smith  |  Founder & CEO

Delays, speed bumps, and scope creep are found in almost any search optimization project. Even the most capable teams run into walls where the work grinds to a halt. The development team might have more pressing problems to handle or a code freeze could prevent any work from getting done.

This is frustrating for SEO professionals who want to improve their company’s organic search efforts while maximizing the value from their search partners. How can they make necessary code changes when the development team won’t answer their calls?

A few SEO professionals, including the team at Trinity Insight, have started to explore alternative options to affect change. By testing how Google interprets Javascript, we can use tools like Google Tag Manager (GTM) and CDN programs to improve SEO — at least until the development team has time for our projects.

SEO Change With GTM

Google Tag Manager is one of the most marketer-friendly development tools available. You don’t need a programming degree or experience in IT to learn how to add code and tags to your site. In an article for Moz, Sam Nemzer provided a few case studies for how brands can use GTM to improve SEO through JavaScript. A few of these examples include:

  • Switchboard tags that replace “www” with “m” depending on the location (desktop or mobile) that the user is browsing from.
  • No Index tags that tell search crawlers to ignore certain pages. (Nemzer cautions users to avoid accidentally applying noindex tags to every page.)
  • Canonical tags that direct crawlers to the right pages to index instead.
  • Structured data tags that add information to your product pages.

Eoghan Henn at SearchViu ran his own tests improving SEO through Javascript and was able to change page links, titles, and even meta descriptions. The changes were reflected in the search console and in Google’s index within 60 days.   

The ability to make these changes are essential in the world of eCommerce. Retailers often have tens of thousands of product pages and need to quickly make changes across the entire site or to a specific few products. Considering organic traffic can account for 20-50% of overall eCommerce revenue, there is no room for error because of bad SEO or improper tags or poorly written meta descriptions.

SEO Change With CDNs

SEO professionals who aren’t able to accomplish their goals through GTM can consider making changes on the server side. Through this strategy, you would be able to write code that changes everything from your headers and content to the behavior and feel of your website because of your CDN.

One of the top products on the market for this so far is Cloudflare Workers, which allows marketers to write Javascript that doesn’t impact the standard code of a website. This tool is similar to GTM and can be used in a pinch to solve problems related to SEO.

“Service Workers are a feature implemented by modern browsers which allow you to load a script which intercepts web requests destined for your server before they hit the network, allowing you a chance to rewrite them, redirect them, or even respond directly,” Kenton Varda explains on Cloudflare.

Additionally, Amazon Web Services has similar capabilities, but its technology is more rigid.

Whether you want to use Cloudflare or AWS (or even just stay in GTM) to improve SEO through Javascript, we recommend starting small and running tests along with way. It is easier to catch and fix a small mistake than to roll out a completely new change and then realize something in your plan went horribly wrong.  

Case Study: Trinity Insight

It’s one thing to read about SEO improvements through GTM and CDNs, it’s quite another to actually utilize them yourself. One of our clients recently approached us with a problem that we ended up solving with JavaScript changes.

The client wanted to expand their international traffic but kept getting hreflang errors, mixing the languages of UK English and US English. Our first strategy was traditional hardcoding. Unfortunately, both the US and UK sites referenced the same code. Then we turned to GTM. Instead of referencing the code, we developed hreflang tags that fired depending on the ccTLD (country code top-level domain). We were able to fix the problem and find a scalable solution without involving the development team and driving up our hours and labor costs.

It took us a few weeks to fully see the impact of the change in Search Console, but you immediately notice the dropoff of errors taking place without any modifications to the core code.

javascript through seo

SEO Through Javascript Is Not the New Standard

While you might think that working in GTM and through client CDNs might be the best new solution to circumventing development teams, most SEO professionals only recommend using these steps when there are limited options available. These are strategies when you need something done quickly or there are no alternatives to choose from. There are multiple reasons for this.

  • Google has stated that it renders canonical tags in the source code, not GTM. While many SEO tests have disproved this and found that the canonical tags are rendered accurately, it is always in the best interest of webmasters to stay on Google’s good side.
  • You cannot create new pages easily with this methodology. It can only be used to modify existing pages.
  • Your solutions may break over time with no way to tell when or how to fix them. In many cases, your GTM or CDN solutions will be temporary fixes until you come up with something more permanent.   

We recommend implementing changes through Javascript as a way to get a quick solution when you need it, but also to create a use case for the problem. When your client or client’s management team sees the SEO benefits and site improvements caused by the quick fix, they can understand the importance of investing in a more permanent solution.

If you find yourself blocked by your development team and need to improve your organic search fast, SEO through JavaScript strategies can help you come up with a plan that doesn’t require deployment or extensive hours of work. You can solve your problems quickly until your development team has the time and resources for a more permanent solution.

Table of Contents

The First Step to Fast SEO Growth

Outline the core pillars to your technical and content SEO strategies, and take your SEO to the next level with our free SEO Playbook (PDF).

About Trinity

Helping online brands grow since 2006. How can we help you? Find out today!

Get a FREE website diagnostic consultation and report for your site.


How to Scale SEO Work NOBODY Wants to Do to Grow Traffic