Analytics

How to Add Heatmaps and Session Recordings With Google Tag Manager

Install heatmaps and session recordings through Google Tag Manager without touching your site's code—tag setup, triggers, consent configuration, and troubleshooting.

Purushottam Kumar Suman
Purushottam Kumar SumanSeptember 18, 20268 min read
Founder & CEO, DeepSync
Google Tag Manager container with heatmap tag

Marketers often can't wait for a developer sprint to add a script. If your site already has Google Tag Manager, you can add heatmaps and session recordings yourself in about ten minutes.

Table of Contents

  1. Before You Start
  2. Step-by-Step GTM Setup
  3. Choosing the Right Trigger
  4. Consent Mode and CMP Settings
  5. Testing With Preview Mode
  6. Troubleshooting
  7. Key Takeaways

Before You Start

  • Publish access to the GTM container.
  • A DeepSync project for your domain (free).
  • Your tracking snippet from Settings → Install.

Native install is still better when possible

GTM adds a small delay before tags fire, so the very first moments of a page load may be missed. If you can add the script directly to your site's head, do that. Use GTM when you can't touch the code.

Step-by-Step GTM Setup

  1. In GTM, go to Tags → New.
  2. Choose Tag Configuration → Custom HTML.
  3. Paste the DeepSync loader snippet.
  4. Under Triggering, choose Initialization – All Pages if available, otherwise All Pages.
  5. Name it "DeepSync – Session Replay & Heatmaps" and Save.
  6. Click Submit → Publish.

Reference: Install via Google Tag Manager.

Choosing the Right Trigger

TriggerWhen to use
Initialization – All PagesBest: fires earliest
All Pages (Page View)Good default
DOM Ready / Window LoadedAvoid—you'll miss early interactions
History ChangeNot needed; DeepSync tracks SPA route changes itself

If your container uses a consent management platform (OneTrust, Cookiebot, CookieYes, etc.):

  1. Decide which consent category DeepSync belongs to (often "analytics" or "statistics").
  2. Make sure the tag is allowed to fire under that category.
  3. If your DeepSync project is in consent-required mode, add a tag that calls the consent function when the visitor accepts. See cookie consent and session replay setup.

The most common GTM problem: the tag is blocked under a consent category, so it never loads—even for visitors who accepted.

Testing With Preview Mode

  1. Click Preview in GTM and open your site.
  2. Confirm the DeepSync tag shows under Tags Fired.
  3. Browse a few pages.
  4. Check Sessions in DeepSync.

Troubleshooting

  • Tag fired but no sessions: Consent-required mode without a consent call. See no data.
  • Tag not firing: Trigger or consent category blocking it.
  • Sessions missing first seconds: Expected with GTM; move to a native install if it matters.
  • Duplicate sessions: The snippet is installed both in GTM and in the site code. Remove one.

Key Takeaways

  • GTM lets marketers install heatmaps and recordings without code changes.
  • Use the earliest trigger available.
  • Configure your consent platform so the tag can fire.
  • Prefer native installs when you can.

Conclusion

Ten minutes in GTM and you'll be watching how real visitors use your site by the end of the day.

Start free.

Frequently Asked Questions

Was this article helpful?

Ready to understand
users like never before?

Join thousands of teams who use DeepSync to uncover insights,improve experiences, and build better products—faster.

Quick & easy onboarding
See results in real time
Enterprise-grade security