ClickTag Implementation for HTML5 Banners
The correct way to implement clickTag for Google Ad Manager, Campaign Manager 360, and other ad servers.
What is a ClickTag?
A clickTag is a JavaScript variable that ad servers use to track clicks on HTML5 banner ads. When a user clicks the banner, the ad server replaces the default URL with the campaign's click-through URL, enabling click tracking and dynamic destination URLs.
The Correct Pattern
Google Ad Manager scans the <head> section of your HTML for a specific pattern. Here is the correct implementation:
<!DOCTYPE html>
<html>
<head>
<meta name="ad.size" content="width=300,height=250">
<script type="text/javascript">
var clickTag = "https://www.example.com";
</script>
</head>
<body>
<div id="banner" onclick="window.open(window.clickTag)">
<!-- Your banner content -->
</div>
</body>
</html>
var clickTag declaration must be (1) in the <head>, (2) a global variable, (3) named exactly clickTag (case-sensitive), and (4) not minified or obfuscated.
How GAM Processes ClickTag
- You upload the HTML5 ZIP to Google Ad Manager
- GAM scans the
<head>forvar clickTag = "..." - If found, GAM shows "ClickTag detected" in the creative preview
- At serve time, GAM replaces the default URL with the click-through URL from the line item
- Clicks are tracked through GAM's redirect system
Common Mistakes
clickTag inside <body>
GAM only scans <head>. If your clickTag declaration is in the body, it won't be detected.
<!-- WRONG: clickTag in body -->
<body>
<script>var clickTag = "https://example.com";</script>
</body>
<!-- CORRECT: clickTag in head -->
<head>
<script>var clickTag = "https://example.com";</script>
</head>
clickTag inside a function or IIFE
The variable must be global. Wrapping it in a function, IIFE, or module makes it invisible to GAM.
<!-- WRONG: not a global variable -->
<script>
(function() {
var clickTag = "https://example.com";
})();
</script>
<!-- CORRECT: global variable -->
<script>
var clickTag = "https://example.com";
</script>
Using let or const
Some ad servers specifically look for var. Using let or const may not be detected.
<!-- WRONG: may not be detected -->
<script>const clickTag = "https://example.com";</script>
<!-- CORRECT: use var -->
<script>var clickTag = "https://example.com";</script>
Minified or obfuscated code
GAM uses regex pattern matching. If your build tool minifies the variable name or restructures the declaration, detection fails.
Missing ad.size meta tag
GAM needs the ad.size meta tag to know the banner dimensions. Without it, the creative may not display correctly.
<meta name="ad.size" content="width=300,height=250">
Click Handler Best Practices
Always use window.open(window.clickTag) instead of just clickTag — this ensures the global variable is used even if there's a local scope collision:
<!-- Best practice -->
<div onclick="window.open(window.clickTag)">...</div>
<!-- Also works -->
<script>
document.getElementById('banner').addEventListener('click', function() {
window.open(window.clickTag);
});
</script>
Platform Differences
| Platform | Variable Name | Detection Method | Notes |
|---|---|---|---|
| GAM | clickTag | Regex in <head> | Most common. Requires var declaration. |
| CM360 | clickTag | Enabler API | Uses Enabler.exit() for click tracking. |
| DV360 | clickTag | Enabler API | Same as CM360. |
| Sizmek | clickTag | EB.clickthrough() | Sizmek SDK required. |
Debugging ClickTag Issues
- Check GAM creative preview: Upload your ZIP and check if "ClickTag detected" appears
- View source: Open the HTML file and verify
var clickTagis in<head> - Browser console: Open the banner in a browser and type
window.clickTag— it should return the URL - Click test: Click the banner and check if
window.openis called with the correct URL