Home
GTM Scripts

⚙️ GTM Script Library

11 copy-paste JavaScript scripts for Google Tag Manager, optimized for B2B funnels and conversion tracking.

💻

Complete Source Code

Ready-to-use JavaScript code blocks for immediate GTM implementation

⚙️

GTM Setup Guide

Step-by-step instructions for configuring each script in Google Tag Manager

🎯

Real Use Cases

Practical examples and configuration options for your specific needs

🎯

Dynamic UTM Parameter Capture

Campaign Attribution Foundation

Attribution

Captures UTM parameters from URL, stores in localStorage, and pushes to dataLayer for persistent campaign attribution and session tracking.

Difficulty

Beginner

Category

Foundation

Use Case

Perfect for B2B websites that need persistent campaign attribution across sessions

Key Features

  • URL parameter extraction
  • localStorage persistence
  • DataLayer integration
  • Session management

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
📊

Traffic Source Mapper

Comprehensive Source Attribution

Attribution

Captures first visit source, interaction level, and logs with timestamp for comprehensive traffic source analytics.

Difficulty

Beginner

Category

Foundation

Use Case

Essential for understanding true traffic source attribution and customer journey mapping

Key Features

  • First-touch attribution
  • Source classification
  • Interaction logging
  • Timestamp tracking

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
🔗

UTM Transfer Script

Parameter Preservation

Attribution

Transfers UTM parameters to all outbound or internal links for complete attribution tracking across domains.

Difficulty

Beginner

Category

Foundation

Use Case

Crucial for multi-page funnels and external link tracking without losing campaign data

Key Features

  • Link attribution
  • Parameter preservation
  • Cross-domain tracking
  • Attribution continuity

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples

Time-of-Day Behavioral Tagger

Temporal Visitor Segmentation

Behavioral

Segments visitors by time of day and pushes time_segment to dataLayer for behavioral analysis.

Difficulty

Intermediate

Category

Tracking

Use Case

Great for businesses with time-sensitive offers or different messaging for business hours

Key Features

  • Time-based segmentation
  • Behavioral tagging
  • DataLayer events
  • Temporal analytics

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
📹

Video Engagement Tracker

YouTube Milestone Tracking

Engagement

Tracks engagement on YouTube videos: play, pause, 25%, 50%, 75%, 100% completion rates with detailed analytics.

Difficulty

Intermediate

Category

Tracking

Use Case

Perfect for SaaS companies with product demo videos or educational content

Key Features

  • YouTube API integration
  • Milestone tracking
  • Engagement analytics
  • Demo video insights

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
📝

Form Abandonment Tracker

CRO Diagnostics

CRO

Tracks if users start filling a form but don't submit within specified time for conversion rate optimization.

Difficulty

Intermediate

Category

Engagement

Use Case

Essential for identifying friction points in lead generation forms and checkout processes

Key Features

  • Form interaction detection
  • Abandonment timing
  • Field-level tracking
  • Drop-off analysis

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
🎯

Live Session Intent Scorer

Real-time Intent Classification

Lead Scoring

Monitors scroll depth, clicks, and time on page to classify visitor intent as low, medium, or high in real-time.

Difficulty

Advanced

Category

Engagement

Use Case

Perfect for sales teams to prioritize leads and trigger personalized outreach based on behavior

Key Features

  • Behavioral scoring
  • Intent classification
  • Real-time analysis
  • Engagement metrics

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
🔄

Smart UTM-Based Content Swapper

Dynamic Content Personalization

Personalization

Dynamically swaps content like headlines, CTAs, or images based on UTM parameters for personalized experiences.

Difficulty

Intermediate

Category

Personalization

Use Case

Ideal for campaign-specific landing pages and personalized user experiences

Key Features

  • Dynamic content switching
  • UTM-based logic
  • A/B testing support
  • Campaign customization

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
💬

Dynamic Testimonial Switcher

Industry-Based Social Proof

Personalization

Changes testimonial blocks or client logos based on utm_industry or persona tags for relevant social proof.

Difficulty

Intermediate

Category

Personalization

Use Case

Perfect for B2B companies serving multiple industries with different use cases

Key Features

  • Industry targeting
  • Persona-based content
  • Social proof optimization
  • Dynamic testimonials

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
🔄

Visitor Frequency Personalizer

Return Visitor Optimization

Personalization

Tracks visit frequency and personalizes content for returning visitors with progressive messaging strategies.

Difficulty

Intermediate

Category

Personalization

Use Case

Great for nurturing prospects through multiple touchpoints with escalating value propositions

Key Features

  • Visit frequency tracking
  • Returning visitor logic
  • Progressive messaging
  • Engagement escalation

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples
🌍

Weather/Geo-based Personalizer

Location-Aware Content

Advanced

Fetches geolocation and weather data to tailor messaging based on visitor location and weather conditions.

Difficulty

Advanced

Category

Personalization

Use Case

Perfect for location-specific offers, weather-dependent products, or regional messaging

Key Features

  • Location detection
  • Weather API integration
  • Geographic personalization
  • Contextual messaging

Implementation

📋Copy-paste JavaScript code
⚙️GTM Custom HTML tag setup
🎯Configuration examples