Skip to content

Instantly share code, notes, and snippets.

@deeman
Last active February 8, 2020 16:02
Show Gist options
  • Select an option

  • Save deeman/02e313c4c21b1dc22244eece5d99a055 to your computer and use it in GitHub Desktop.

Select an option

Save deeman/02e313c4c21b1dc22244eece5d99a055 to your computer and use it in GitHub Desktop.
Setup Google Analytics tracking via PHP-hook
//Add Google Analytics function
function google_analytics() {
include_once("analyticstracking.php");
}
//Add tracking action, set Google Analytics
add_action('wp_head', 'google_analytics');
Step 1: Create a PHP-file in the rot, name it "anylyticstracking.php".
Step 2: Copy the tracking script from your Google Analytics account and paste it into the "analyticstracking.php"-file.
Step 3: Go to your Child Theme and edit your "functions.php"-file. Copy/Paste code abowe.
Save.
Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment