What's the easiest way to insert a global site tag on a WordPress site?
 by Kristi Hagen

What's the easiest way to insert a global site tag on a WordPress site?

  • I'm being asked to insert a global site tag {gtag('config', 'AW-xxxxxxxxxxxx');} into the Thank You page of a client's site by the Google Digital Account Exec. This is a WordPress site built by others. I attempted to insert this into the functions.php file (that seems easiest), and got an error when doing so:

    Your PHP code changes were rolled back due 
    to an error on line 45 of file
    Please fix and try saving again.
    Uncaught Error: Call to undefined function gtag() 
    in wp-content/themes/ipropads/functions.php:45
    Stack trace:
    #0 wp-settings.php(426): include()
    #1 wp-config.php(95): require_once('/users/ipropads...')
    #2 wp-load.php(37): require_once('/users/ipropads...')
    #3 wp-admin/admin.php(31): require_once('/users/ipropads...')
    #4 wp-admin/theme-editor.php(10): require_once('/users/ipropads...')
    #5 {main}

    Can you give me a hint on the easiest way to accomplish this?


The easiest way to do this is to add the SOGO Header Footer plugin - https://wordpress.org/plugins/oh-add-script-header-footer/

This plugin lets you add custom code into an individual page on a WordPress site. It's great for adding page specific items like Structured Data markup, Javascript, or tracking codes - like you're wanting to. To use it just:

  • Login to the backend of the WordPress site and navigate to the Plugins > Add New page.
  • Use the Add New button at the top of the page to search out and add the SOGO plugin.
  • Once activated, you'll find two new SOGO editing sections (header and footer) at the bottom of every page WordPress editor interface.
  • Paste the tracking code in the SOGO header field of the Thank You page, hit Update on the entire page and you're good to go.SEN article end

Already a member? Sign in here

Read the rest of this article,
and get all this for only $1.

  • The Search Engine Strategies Updates for June 2021
  • SEN's Monthly Marketing Podcast for Strategies on the Go
  • Ultimate Guide to Avoiding Google Penalties
  • The Complete Site Audit Checklist
  • The Definitive Local Search Audit Checklist
  • 100's of Strategic SEO Articles and Q&As
  • The Internet Marketing Glossary
  • The Pro SEO's Local Search Directory List
  • 2019 Unfair Advantage SEO Beginner's Book
  • Pro's Ultimate WordPress Plugin Guide
  • The Vault: SEN's Internet Marketing Research Libraries
  • PLUS, as a Full SEN Basic Member, you'll be eligible for hundreds of dollars of discounts on SEO courses ranging from beginner to master on a variety of topics including organic search, local search, and social networking.

  • Your $1 Trial is good for 7 days at which time your card will be charged $29/mo unless you cancel before July 2nd, 2021

 This form is encrypted for your security