Analytics and Tracking

Custom HTML Tag

Also called Custom HTML, raw HTML tag

A Tag Manager tag that runs code you supply yourself, used when no built-in template covers what you need.

Quick facts: Custom HTML Tag

Category
Analytics and Tracking
Also called
Custom HTML, raw HTML tag
Level
Intermediate
Affects
Page speed, data security, tag maintainability
Where to see it
Google Tag Manager (Tags, Custom HTML), browser developer tools
In this article4
  1. How a Custom HTML tag works
  2. Why Custom HTML tags matter
  3. Where Custom HTML tags go wrong
  4. How to use them safely

How a Custom HTML tag works

Most tags in Tag Manager are templates: you choose the vendor, fill in an ID, and the tool writes correct code on your behalf. A Custom HTML tag skips all of that. You paste in your own markup and script, attach a trigger, and Tag Manager injects it into the page whenever that trigger fires.

The code runs inside the page with the same access any other script there has. It can read the page content, set cookies, call another company’s server and change what the visitor sees. Tag Manager offers a few controls — firing once per page or per event, and a legacy option for older snippets — but it does not inspect what your code actually does.

Why Custom HTML tags matter

They are the escape hatch. When a smaller vendor has no Tag Manager template, when a platform publishes its conversion snippet only as raw code, or when a fix has to reach the live site before the next development release, a Custom HTML tag is often the only route available the same afternoon.

They also let a marketer act without waiting for a developer, which on a small team is the difference between tracking a form this week and tracking it next quarter. That freedom is precisely why the tag needs rules around it.

Where Custom HTML tags go wrong

Weight is the first cost. Each one usually loads a file from someone else’s server, and that request competes with the content the visitor came for. On mobile connections, which carry most traffic in Nepal and in the other markets I work in, a container stuffed with pasted snippets becomes a real part of a slow page.

Security is the second. Arbitrary code with full access to the page can read whatever a visitor types into a form, so anyone who can edit and publish the container can, in principle, read customer data. Pasting a snippet from a forum thread or a supplier’s email without reading it is the same as letting a stranger add code to your checkout.

The third is silent breakage. When a vendor updates their snippet, nothing in Tag Manager tells you. The tag keeps firing the old code and the data quietly stops matching what the platform expects.

How to use them safely

Reach for a built-in template or a custom template first and use raw HTML only when neither exists. Read every line before pasting it, keep one purpose per tag so it can later be removed cleanly, and name the tag after what it does rather than after the vendor who sent it. Keep publish rights narrow, because the container is only as safe as the least careful person holding them.

Review the list every few months and delete tags whose campaign has ended. If you cannot tell what a tag on your site is doing, a tracking audit answers that faster than reverse-engineering scripts one at a time.

Do and do not

Do

  • Read every snippet line before pasting it
  • Keep one purpose per tag
  • Delete tags whose campaign has ended

Do not

  • Paste code from an unverified source
  • Give publish rights to everyone who edits
  • Use raw HTML when a template exists

Questions people ask about this

Is a Custom HTML tag bad for page speed?

It can be. The tag itself is small, but most of them load a script file from another company's server, and that request competes with your own content. A few well-chosen tags are rarely the problem. A container that has collected pasted snippets for years usually is, so audit the whole list rather than judging one tag.

Can a Custom HTML tag steal customer data?

It has the technical ability to read anything on the page, including what a visitor types into a form. That is not a flaw in Tag Manager, it is what arbitrary code means. The protection is procedural: read every snippet before publishing, keep the list of people who can publish short, and never paste code from an unverified source.

When should I use a custom template instead?

Whenever the same snippet is needed across several sites, or whenever people who should not be handling raw code need to deploy it. A template wraps the logic in a sandbox, exposes only the fields you choose, and cannot quietly reach the rest of the page. Raw HTML suits one-off cases where no template exists.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.