The Google Analytics: GA4 Configuration tag is now the Google tag. GA4 Configuration tags in a web container will be automatically migrated starting in September. There are no changes to your existing measurement and there is no action required from you. Learn more

WordPress: Set up your Google tag

You can measure behavioral data about your site with Google Analytics and Google Ads. Follow the steps in this article to set up your Google Analytics and Google Ads accounts with WordPress.

Before you begin

You can integrate WordPress with Google Ads or Google Analytics for free. To set up the integration, you’ll need:

  • A valid Google sign-in
  • A Google-provided Javascript code snippet
  • An active WordPress installation

Copy your Google tag code snippet:

<!-- Google tag (gtag.js) -->

<script async src=""></script>


 window.dataLayer = window.dataLayer || [];

 function gtag(){dataLayer.push(arguments);}

 gtag('js', new Date());

 gtag('config', 'TAG_ID');



  1. Sign in to your WordPress backend.
  2. On the menu on the left, click Tools, then select Theme file editor from the dropdown menu.
    • Note: Depending on which theme your WordPress site uses, the header file name might be different. If you use the “WordPress Twenty Twenty One” theme, click Theme Header (header.php) on the right panel to open the code editor. Confirm that there’s a <head> tag on the page.
  3. Paste the Google tag code snippet into the editor within the <head> tag. Click Update file.
    • Note: If you change your WordPress theme, you must repeat this process again as the header.php might be overwritten.

Was this helpful?

How can we improve it?
Clear search
Close search
Google apps
Main menu
Search Help Center