+254725682556 +254725052660 info@ziprof.co.ke
Client Area

SEO

How to Set Up Google Tag Manager on Your Website

Google Tag Manager (GTM) is a free tool that lets you add, edit, and manage tracking and marketing codes on your website through a simple online dashboard, instead of editing your website's files every time you need to add a new tracking snippet. Once GTM itself is installed, you can add things like Google Analytics, a Facebook pixel, or a conversion tracking tag directly from the GTM dashboard, without touching your website's code again.

Step 1: Create a Google Tag Manager Account and Container

  1. Go to Google Tag Manager and sign in with the Google account you want to manage your website's tags with.
  2. Click Create Account.
  3. Enter an account name (usually your business name) and your country.
  4. Under Container name, enter your website's domain name, and set Target platform to Web.
  5. Click Create, then accept the Terms of Service.

Google Tag Manager will immediately show you a code snippet in two parts. This is the installation code you need in the next step.

Step 2: Add the GTM Code to Your Website

The GTM snippet has two parts: one goes in the <head> section of every page, and the other goes right after the opening <body> tag. Both parts are required for GTM to work correctly.

If your site runs on WordPress

  1. Install and activate a plugin that lets you insert code into your site's header and body (search your WordPress dashboard's Plugins > Add New screen for a header/footer code plugin).
  2. Open the plugin's settings page.
  3. Paste the first part of the GTM snippet into the Header field.
  4. Paste the second part into the Body field.
  5. Save your changes.

If your site is a custom-built or static website

This process is the same whether your hosting account uses cPanel or DirectAdmin, since both give you a File Manager for editing your site's files directly.

  1. Log in to your hosting control panel and open File Manager.
  2. Locate the main template file your site uses for every page (often called something like header.php or included at the top of every page).
  3. Open the file for editing and paste the first part of the GTM snippet immediately after the opening <head> tag.
  4. Paste the second part of the snippet immediately after the opening <body> tag.
  5. Save the file, then repeat for any other page templates that don't share the same header/body include.
If you're not comfortable editing your site's code directly, ask your web developer to add the snippet for you. Pasting it in the wrong place is a common reason tags don't fire correctly.

Step 3: Verify the Installation

  1. In your GTM dashboard, click Preview in the top-right corner.
  2. Enter your website's URL and click Connect.
  3. Your website will open in a new tab, with a debug panel confirming that Tag Manager is detected and loading correctly.
  4. Once confirmed, go back to your GTM dashboard and click Submit, then Publish, to make your container live for all visitors.

Until you publish, changes you make inside GTM only show up in preview mode, not to real visitors.

Adding Your First Tag

With GTM installed, you can now add tags without editing your website again. For example, to add Google Analytics:

  1. In your GTM dashboard, click Tags > New.
  2. Choose the Google Analytics tag type and enter your measurement ID.
  3. Set a trigger of All Pages so it fires on every page view.
  4. Save, then Publish the container again.
If your website uses cookies for tracking or advertising tags, Kenyan data protection rules generally expect you to inform visitors and get consent. If you don't already have a cookie notice on your site, it's worth adding one before publishing tracking tags.

For guidance on adding that notice, see How to Add a Privacy Policy and Cookie Consent Notice to Your Website.