Google Tag Manager

Last updated:

|Edit this page

Objective

Integrating PostHog into your website using Google Tag Manager.

Why is this useful?

Google Tag Manager helps you add tags into your website in a codeless way, for services such as marketing and analytics tools.

It is an easy way to integrate PostHog into your website without having to update your codebase.

Prerequisites

To follow this tutorial along, you should:

  1. Have deployed PostHog or be using PostHog Cloud.

Step-by-step instructions

  1. Get your PostHog snippet from your 'Project Settings' or the initial PostHog setup

  2. Access your Google Tag Manager dashboard and navigate to the desired account/container that is integrated with the website you want to add PostHog tracking to

  3. Click to add a new tag:

    GTM Dashboard

  4. On the page to configure a new tag, add your PostHog snippet as a 'Custom HTML Tag' under 'Tag Configuration'

  5. For the trigger, select the default "All Pages - Page View" trigger and then click 'Save' on the top right corner of the drawer

  6. Back on the main dashboard, click 'Submit' to update your website with the new PostHog tag

  7. You're done! PostHog is now configured for your website.

To confirm PostHog is configured correctly, visit your website and then check if the events from your session appear in PostHog. Note that this may take a few minutes.

Questions?

Was this page useful?

Next article

Laravel

PostHog makes it easy to get data about traffic and usage of your Laravel app. Integrating PostHog enables analytics, custom events capture, feature flags, and more. This guide walks you through integrating PostHog into your Laravel app using the PHP SDK . Installation First, ensure Composer is installed. Then run composer require posthog/posthog-php to install PostHog’s PHP SDK. Next, initialize PostHog in the boot method of app/Providers/AppServiceProvider.php : You can find your…

Read next article