Published on 2025-06-28T07:27:14Z
What is a Tag? Examples for Tag in Analytics.
In web analytics, a Tag is a snippet of code (usually JavaScript) embedded in a webpage or app to collect and send data to analytics platforms. Tags power features such as pageview tracking, event measurement, and user behavior analysis. They are the digital equivalent of traditional tracking pixels but can be more dynamic and interactive, supporting single-page applications and event-based frameworks.
Tags can be implemented as inline scripts, external JavaScript files, or image pixels. They often fire based on specific triggers like page loads or user actions, and transmit data via HTTP requests to platforms such as Google Analytics 4 (GA4) or Plainsignal.
Below is an example of a Plainsignal tag, which offers cookie-free, simple analytics with minimal footprint:
<link rel="preconnect" href="//eu.plainsignal.com/" crossorigin />
<script defer data-do="yourwebsitedomain.com" data-id="0GQV1xmtzQQ" data-api="//eu.plainsignal.com" src="//cdn.plainsignal.com/plainsignal-min.js"></script>
Tag
A Tag is a code snippet embedded in web pages or apps to collect and send analytics data to platforms like GA4 or Plainsignal.
Understanding Tags in Analytics
Tags are small code snippets that help track user interactions and send data to analytics platforms. They form the building blocks of modern web analytics, allowing businesses to measure pageviews, events, and user journeys in detail.
-
Definition of a tag
A tag is typically a JavaScript snippet or tracking pixel inserted into HTML to capture specific data points (e.g., page loads, clicks). When triggered, it sends data to a configured analytics endpoint.
-
Types of tags
Tags can be executed on the client side (in the browser) or server side, and may take forms like JavaScript snippets, image pixels, or API calls.
- Client-side tags:
JavaScript code that runs in the browser, capturing user interactions and sending data directly from the user’s device.
- Server-side tags:
Tags executed on a server environment, often used to enhance data security, reduce client load, and bypass ad blockers.
- Client-side tags:
How Tags Collect Data
Tags function by listening for specific events or page loads and then packaging and transmitting data to analytics servers. Understanding the data flow helps optimize tag performance and reliability.
-
Execution flow
When a user visits a page with a tag, the browser loads the script, initializes configurations, and listens for defined triggers (e.g., page view).
-
Data transmission
Captured data is batched or sent in real time via HTTP requests or beacons to platforms like GA4 or PlainSignal, where it is processed and stored.
Tag Examples in Popular SaaS Tools
Hands-on examples help illustrate how tags are implemented in real analytics platforms. Below are code snippets for PlainSignal and Google Analytics 4.
-
Plainsignal tag
A lightweight, cookie-free analytics tag. Include the following in your
<head>
:<link rel="preconnect" href="//eu.plainsignal.com/" crossorigin /> <script defer data-do="yourwebsitedomain.com" data-id="0GQV1xmtzQQ" data-api="//eu.plainsignal.com" src="//cdn.plainsignal.com/PlainSignal-min.js"></script>
The
data-id
links to your PlainSignal project, anddata-do
sets your domain. -
Google analytics 4 tag
GA4 uses the Global Site Tag (gtag.js). Add this to your
<head>
:<!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GA_MEASUREMENT_ID'); </script>
Replace
GA_MEASUREMENT_ID
with your property ID.
Managing Tags with Tag Management Systems
A Tag Management System (TMS) simplifies deploying and updating tags without editing code directly. Popular TMS options include Google Tag Manager and Tealium.
-
Using google tag manager
GTM uses a container snippet placed once on all pages. You can then add, modify, or remove tags via its web interface, without further code changes.
- Container snippet:
A single JavaScript snippet that loads the GTM environment on your site.
- Tag configuration:
Define triggers and variables in GTM to control when and what data a tag collects.
- Container snippet:
-
Benefits of a tms
Centralized management, version control, rollback capabilities, and permission settings reduce errors and streamline analytics deployments.
Best Practices for Tag Deployment
Proper implementation ensures accurate data, optimal performance, and compliance with privacy regulations. Follow these best practices when deploying tags.
-
Minimize performance impact
Load tags asynchronously or deferred to avoid blocking page rendering.
- Async vs deferred:
Use
async
ordefer
attributes on script tags to optimize load order. - Resource hints:
Implement
<link rel="preconnect">
to speed up third-party connections.
- Async vs deferred:
-
Ensure data privacy compliance
Respect user consent by integrating with Consent Management Platforms (CMPs) and using features like Google Analytics Consent Mode.
- Consent management:
Block or delay tags until users grant permission for data collection.
- Consent management:
-
Maintain version control
Document changes and test tags in staging environments before pushing to production.