October 15, 2017

How to Add Google Analytics to WordPress With a Plugin

2017-10-15T10:40:00+05:30

Are you searching for best google analytics wordpress plugin, add google analytics to wordpress without plugin and google analytics yoast wordpress analytics dashboard. You can access google analytics dashboard for wp and add google analytics access code using external plugins for wp. Here is a post on how to access google analytics dashboard for wp (gadwp) and install google analytics in wordpress theme.

Here is the best way to Add Google Analytics to WordPress With a Plugin for beginners. No need to edit the PHP code. Editing php code may lock you out from admin dashboard. Always use plugins to solve the problems. Here is the best Google Analytics plugin for WordPress where you can add Google Analytics tracking code to WordPress easily.

Add Google Analytics to WordPress With a Plugin

  1. Go to Wordpress 
  2. Select Add A Plugin
  3. Search for GA Google Analytics
  4. Select Install & Activate
  5. Go to Plugins
  6. Open the GA Google Analytics Plugin
  7. Add the Google Analytics Tracking ID inside it
  8. Save the changes

Watch Tutorial Video


How to Add Google Analytics to WordPress Without a Plugin

  1. Go to WordPress
  2. Go to Editor
  3. Find Theme header .php file
  4. Open header.php file
  5. Add Google Analytics Tracking code
  6. Save changes
Many users try to edit the php files using Editor and get locked outside. Many get these errors.

"Parse error: syntax error, unexpected ‘}’ in /……../………/…………/ ga_analyticstracking.php on line 23.

Here is what I have:

<?php
/*
Plugin Name: Google Analytics Plugin
Plugin URI: XXXXXXXXXXXXX
Description: Adds a Google analytics tracking code to the of your theme, by hooking to wp_head.
Author: Dolvin
Version: 1.0
*/
?>

function ga_analyticstracking() { ?>

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘XX-XXXXXXXX-X’, ‘auto’);
ga(‘send’, ‘pageview’);

<?php }
add_action( 'wp_head', ‘ga_analyticstracking’, 10 );"

"The plugin generated 2 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘XXXX’, ‘auto’);

ga(‘send’, ‘pageview’);

<?php }
add_action( 'wp_head', 'wpmudev_google_analytics', 10 );"

I suggest to add Analytics using the plugin above.

Kindly spend 5 seconds to share this post



Search Here

Whats Hot

About Author