On a fairly large website in which I act as the technical owner/ administrator, it was recently mandated that all outbound hyperlinks (both new and existing) open in a new tab.
Since we’re not using WordPress and are unable to acquire IT resources to assist with an automated solution, I asked the team “how long will it take” to go through 700+ pages of content looking for external links and adding the target attribute “_blank” to each and every one of them? Most people said 5 to 10 minutes.
If we calculated (7 minutes per page) x (700 pages) = (4,900 minutes). That’s 81 hours, or roughly two weeks of work. Ugh!
Google Tag Manager Saves the Day
From concept to implementation it took me less than 30 minutes to get the job done. Much better than spending 80+ hours! Let me show you what I did.
Create a GTM Tag
Go into GTM and create a new tag named HTML – LinkOpener – All Pages. Set the Tag Type to Custom HTML. Paste the code below into the source code window. Set the Firing Trigger to All Pages.
The script below will add target=”_blank” rel=”noopener noreferrer” to every link that does not point to your own domain.
Full-view of Tag and Firing Trigger
Should External Links Open in a New Tab?
- Those that say no argue for accessibility and mobile use considerations.
- Those that say yes argue for SEO, lower bounce rate in their analytics reports, tricking users and more.
Since there doesn’t seem to be a consensus, I think it depends on the type of visitor your website attracts.
Here on my website I decided to open external links in a new tab. I also included a visual cue () to notify users of what’s going to happen. My reasoning is that I’m a technical blog and reference many external sources. Users will likely want to look at said reference material at a later date. By opening the links in a new tab it more easily allows them to do so.