Do I Need To Use Anchor Tag IDs? 

 

In my previous blog post I went in depth about anchor tag IDs and the fact that they’re a completely optional part of web development. However as you delve deeper on the best way to track everything on your website, you’re going to have to weigh the pros and cons of whether or not you need these identifiers. 

Why aren’t anchor tag ids normally used? 

Anchor tag ids aren’t always used because adding them means more code. Generally speaking, the more code you have, the longer it is to develop and the slower the page loads. This is not the case 100% of the time, but think of it like a book – it’s going to take a lot longer to read a 200 page book than a 20 page book, unless your 20 page book is written at a university level and your 200 page book is written at a 3rd grade level. Same concept. But more than load time, the development time is really what makes it stand out. You’re essentially paying a developer more money to add something that does nothing on the page. Well, mostly. 

Why do you want to put anchor tag ids on a page? 

Now that I’ve discounted anchor tag IDs, citing page speed and development time, let me tell you about their benefits. Unless you have a super fancy web analytics program, you’re probably getting all your web analytics tracking from Google Analytics.  

Google Analytics is great in a lot of ways, but it has its limitations. With Google Analytics you can tell which pages people visited, but not which specific link they clicked on. All Google Analytics cares about is that you went to the next page, not that you interacted with one link more than another link. 

One of the best ways to tell which specific link was clicked is by adding that anchor tag ID, because as I mentioned before – it’s the only one on the page. It’s important to note though that it’s totally possible to track an individual link without an anchor tag ID, however I don’t recommend it. 

For example, many people track a specific link click based on the anchor text. This works great unless your anchor text is the same for all buttons (“Buy now!”) or decide that you need more keyword intensive anchor text for SEO and forget to tell your tracking team. Having the anchor tag ID is also especially helpful if you change your anchor text for an A/B test. Otherwise, you’re stuck trying to do some pretty complex regular expressions, which increases your opportunity for error. 

Summary 

Code smarter, not harder. If you’re looking to perform A/B testing in the future or if tracking the most successful CTA is important to you, it may be beneficial for you to put IDs on your anchor tags. However, if you’ve got links all over your website that you have no intent on tracking in the future, then my advice is to hold off on the anchor tags. Instead, avoid the anchor tag IDs, get your website to load quicker and have a website that’s developed faster. 

 

Stay in the know with email updates!

* indicates required

What Is An Anchor Tag and What Is An Anchor Tag ID?

 

Ahoy mateys! The next two blogs are all about anchors. At the end of these two blogs, you’ll know the what is an anchor tag, anchor text, and most importantly, anchor tag IDs. You’ll also know whether or not you need anchor tag IDs for better tracking on your website.

What is an anchor tag? 

Any time you have a clickable element in your website, you will also have multiple attributes associated with that element. When you group all those attributes together in coding, it’s called a tag. When we talk about an anchor tag, we’re describing the clickable element (i.e. a link) you have on your website and all the attributes associated with that clickable element.  

You’ll notice I said clickable element – not url. That’s because everything that’s clickable doesn’t have to necessarily be a url. You can have clickable images, hashes (#) that just bring you down farther on a page, and more. When we talk about attributes associated with that clickable element we can be talking about the different text on a link (anchor text), an ID associated with that particular link (anchor tag ID), and what that link goes to (href). 

what is an anchor tag

What are anchor tag IDs: A deeper dive 

As you begin to delve into Google Tag Manager (or any sort of basic web development for that matter), the subject of ids for anchor tags may come up. It’s even more likely to enter the conversion when you’re talking about click tracking (tracking clicks throughout your website).   

Anchor tag IDs are used to specify an element’s (a link’s) unique identifier. The key word here is unique – while you can have the same id throughout the site, you can’t have two of the same id on the same page.  

You’ll likely see anchor tag ids shortened as an “a id” – but don’t call them that. 98 out of 100 web developers won’t know what you’re talking about (and it makes you look a lot less knowledgeable). The best way to describe the “a id” is as an anchor tag id or an id for the anchor tag. These terms can be used interchangeably.  

IDs for anchor tags are completely optional, although depending on the documentation you see, it may seem as though it’s a standard in web design or you absolutely can’t do click tracking without it. Spoiler – they’re not a standard and you absolutely can do click tracking without it. 

Summary 

Anchor tags are what makes it possible for you to click on a website element and have it go somewhere. Sometimes you’ll see developers add an ID on them, but not always, as IDs are a completely optional part of web development. 

Stay tuned for whether or not you need anchor tag IDs for tracking in my next blog!

 

Stay in the know with email updates!

* indicates required