Categories: WordPress

How to Add Google Analytics to WordPress

You have created a WordPress website and now you want to monitor the traffic on your site.

There is a simple way of monitoring the traffic to your newly built website. Now it’s time to get into how to create a plugin and activate. I know it might seem a little confusing at first but this is very simple. The way that Google tracks your traffic is by inserting the snippet of code into the head of each page. With WordPress, you only have to use the code one time and activate the plugin.

Get Started With What You Will Need

There are few options you could use when creating the plugin.

You could use a code/text editor of your choice. I prefer to use Atom. You will need an FTP access to the site to upload the plugin file, as in Filezilla.

Also, you want to make sure that within the header.php file you see the wp_head hook. How to check your WordPress header.php file. On your left sidebar, hover over Appearance and at the bottom of pop-up, you will click on Editor. From that screen, you will see the header.php file on the right-hand side. Click there and you shall see the wp_head hook.

Now let us go through the steps to creating the plugin.

1. Open your text editor and create the file. I named my file wprockcoconut-google-analytics.php, you could name your file anything you want. Next, you will want to create the plugin name to identify with.

 

How to create a plugin for Google Analytics to your WordPress

 

2. Next, write the next line of code under the plugin information in the same file.

 

How to create a plugin for Google Analytics to WordPress

 

3. Next, copy the code that Google Analytics give you. I have cut out my account information for security purposes.

 

How to create a plugin for Google Analytics and WordPress

 

4. Next, paste that code from Google Analytics in your plugin file, including script tags.

 

How to create a plugin for Google Analytics and WordPress

 

5. After saving this file, you will now locate the folder within your WordPress to upload to. The Folder path would be wp-content/plugins. Once you upload the file to this location, go to your WordPress dashboard and click on Plugins. Next, you will have the list of all the plugins that you have installed and now you should see your plugin that you have created. Once located click on the Activate button and your finished.

 

How to create a Google Analytics Plugin for WordPress

 

Now you have completed the steps of making your own plugin for Google Analytics.

 

Note: Workaround if you do not use a code/text editor and do not use an FTP access application. 

  1. Open cPanel
  2. Click on File Manager
  3. Locate your WordPress Files in Public_html
  4. Go to wp-content/plugins
  5. Click create file
  6. Name your file with the .php ext
  7. Then you could highlight that file and right click to code edit
  8. Then you could write the same code and paste your Analytics snippet from Google also
  9. Save your file and then activate your plugin

 

If you would like more information regarding Web Design. Contact us today through our contact form or by phone.

Contact Us Click to Call
Robert Montoya Director of Business
Robert Montoya

Share
Published by
Robert Montoya

Recent Posts

What are Some of the Hardest Parts of Digital Marketing?

Doing digital marketing well takes time and practice. And like anything, there are definitely some…

3 years ago

Goals Every New Business Should Set for Themselves

As a new business, there is a long list of things you’re trying to accomplish.…

3 years ago

How to Prevent Leads From Falling Through the Cracks

There are a lot of tools and resources at your disposal when it comes to…

3 years ago

How to Get More Quality Leads for Your Business

If you own a business, you need to be able to generate as many leads…

3 years ago

How to Get Your Customer Involved in Lead Generation

In your small business, your customers are your best support system, and because of that,…

3 years ago

What Every Business Needs to Establish a Name for Themselves

Starting a business is difficult, but if you can establish a name for yourself, your…

3 years ago