• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Aaron Weiss

  • Home
  • Blog
  • About
  • Contact

WordPress

Learn about WordPress maintenance tips and tricks to make sure your WordPress websites are running at their best.

Plugin Update Failed: How To Fix WordPress Plugin and Theme Permission Errors

December 6, 2019 by Aaron Weiss

Recently, when attempting to update some plugins and themes on my WordPress installation, I can across two errors:

Failure Updating Plugins

An error occurred while updating <plugin name>

WordPress plugin update failure: Update Failed: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.
Example of a plugin update failure. Click to see an enlarged version.

And…

Failure Deleting Plugins

Plugin could not be deleted due to an error: Could not fully remove the plugin(s) my-plugin/my-plugin.php

Could not fully remove the plugin.
Example of a plugin deletion failure. Click to see an enlarged version.

The root of the problem is that same: permissions. I’ve found two ways to correct this if your WordPress website is hosted on a Linux server and you have shell access.

This error and solution is the same for WordPress themes too.

  1. Update the plugins or themes using WP-CLI
  2. Run a Linux command

Update Plugins or Themes with WP-CLI:

WP-CLI is a command line interface for Linux that allows you to complete WordPress tasks and functions using the Linux command line. This can be faster than completing the same many functions tasks within the WordPress Dashboard.

Built into WP-CLI is the ability to update plugins, themes, and even the core WordPress installation from the command line. This circumvents the problem because there are no interfaces with a browser, and therefore no need for the actual web server (usually Apache) getting involved.

  1. Install WP-CLI or use a host that has it installed by default like a2 Hosting.
  2. Run wp plugin update or wp theme update.

However, this is not a permanent solution. But learning the WP-CLI and creating scripts can increase the speed of completing WordPress functions.

Run a Linux Command

This is the best option because we’re actually fixing the problem.

sudo chown -R www-data /path/to/plugin

Replace “/path/to/plugin” which is usually something along the lines of /var/www/html/wp-content/plugins/ewww-image-optimizer, which was an example of the problem I faced.

This will give ownership of the directory back to Apache so that when you update the plugin again through WordPress’s update features, it should work permanently.

Conclusion

These are two great ways in which to correct the ownership issues with WordPress plugin and theme updates. While option 2 is clearly the permanent solution, updating using an automated script found in option 2 might be more helpful if you want to save time maintaining your WordPress website.

Filed Under: WordPress Tagged With: cli, command line interface, linux, linux shell, wordpress, wordpress errors, wp-cli

How My WordPress Website Got Hacked and How I Recovered

November 26, 2019 by Aaron Weiss

My WordPress website was hacked, and it was super embarrassing.

Just when my recent blog post about why you shouldn’t download nulled versions of BackupBuddy was starting to rank well for various keywords and gaining some decent traffic, my site began to redirect to another website. I couldn’t log into my website at all. I wasn’t able to find much information about this particular hack to fix it especially since I couldn’t gain access to my site.

However, I still had access to my server, and because I had an awesome disaster and recovery plan I was able to return my website back to a running instance quickly.

Why did my Website get Hacked?

I have not figured out what exactly happened. It could have been a bad plugin, which is making me reconsider what plugins are really necessary. I’ve always felt that the plugins that I’ve chosen were solid, but time to weed out plugins whose features can be moved to a functions.php file or other implementation.

I had also moved to Austin, TX, and not updated my site as I normally had done. I’d say this was my biggest mistake. I should have found time to maintain my website. I knew this in the back of my mind, and I didn’t commit to it.

How I Recovered My Site

Typically, I wold have ran a BackupBuddy recovery using importbuddy.php. However, since my website and dashboard was redirecting to another website, I was unable to access my site from a browser. Therefore, that was out of the picture.

Since I still had access to my server, I was able to utilize Digital Ocean’s backups and recover my site from a version that was less than one week old. Given that I didn’t have any new publishes or changes made to the website, this was fine and worked.

What are the Plans for the Future?

Essentially, better maintenance and updating of the website and platform on a more regular and automated basis.

I’ve previously created Bash scripts that check the site’s core installation, theme, and plugins for any known CVE vulnerabilities, created a full site backup, then optimizes the database, and notifies my by email was updates are available. However, the CVE vulnerability check stopped working. Since I was busy moving, I never had a chance to see this gap. However, this has been corrected as of late.

I don’t believe in automatic updates as any update can cause problems and I like to test updates, especially core and theme updates, very carefully before I commit. So my future automation will take that into consideration.

How Do I Feel About This Now?

I’m okay about it. It’s embarrassing, but I’ve also realized that it’s okay. It happens. I had a plan to recover and executed it perfectly. This happens with WordPress websites, and it gives me a chance to recognize the gaps in my WordPress maintenance and re-commit to what’s necessary for my website.

The absolute worst thing about this is that I lost lots of momentum with some SEO traffic for my BackupBuddy article, but that’s the name of the game. I believe if I continue to work on creating a great website, I don’t have much to work about long-term and my rankings will return.

Filed Under: Website Administration, WordPress Tagged With: backups, hacked, wordpress, wordpress maintenance

Reasons Not to Download BackupBuddy Nulled

August 1, 2019 by Aaron Weiss

Nowadays, people tend to go for fake products to save some cash, including searching to download BackupBuddy nulled versions. The trend is growing adversely, and to keep things very simple: the source code has been nulled making the plugin unsafe.The biggest irony is using an unsupported and insecure plugin as a part of your websites backup strategy. The chances are downloading BackupBuddy nulled will end up causing more harm than good to your website. You will find yourself spending more money and time to fix your site than what you would have spent on an official BackupBuddy plugin license.

This article will explore the dangers of using a pirated or nulled BackupBuddy plugin, and why a legitimate version is a part of a strong website strategy.

Table of Contents

  • What is BackupBuddy?
  • What is a nulled plugin or theme?
  • Risks of Downloading BackupBuddy Nulled
  • Why You Should Purchase a BackupBuddy License
  • BackupBuddy Nulled: The Evidence is Clear

What is BackupBuddy?

iThemes BackupBuddy LogoBackupBuddy is premium WordPress plugin from iThemes offering a robust set of tools to backup your website. The plugin was originally created in 2010, and ever since it has become a popular WordPress website backup solution.

BackupBuddy allows you to choose how much, how often, and where your website’s data is backed up. Additionally, the plugin provides migration and deployment options for developers.

Malware, hacking, or general mistakes are all risks that website face. BackupBuddy can help you restore your website in minutes. I’ve had to recover this website a handful of times using BackupBuddy. This means that having BackupBuddy plugin for backup purposes will always keep you one step ahead.

iThemes

iThemes is a WordPress plugin and theme company that develops BackupBuddy, as well as an industry-leading security plugin called iThemes Security, and many other WordPress plugins and themes that extend the content management platform’s capabilities. Their plugins are designed for marketers and designers to have easier access to well-designed and functional marketing strategies for their WordPress websites.

What is a nulled plugin or theme?

A nulled plugin or theme is a premium product that has been redistributed and made available online. You can access and download it for free.

Nulled plugins are attractive because they are readily available by third-party individuals. The primary users of these products are often people who don’t have the complete knowledge of the risks. These risks are so huge that they end up creating more than just minor loopholes. In a worst-case scenario, they may collapse your WordPress website. This article discusses why you should not download BackupBuddy nulled on your website.

Legal Implications

The legality of nulled plugins and themes is debated. Most people distributing nulled BackupBuddy plugins claim that it is not an offense because WordPress and its related derivatives are licensed under GNU General Public License (GNU GPL) which is a license governing free software. It states that software that is released with this licence can be used freely, copied, or redistributed by any person.

Among the rights of GPL licensed software is that users can modify it and redistribute the modified version. As much as this is legally true, the redistributed versions tend to have multiple risks that will be discussed below.

Serious website owners tend to avoid nulled plugins or themes. This is because they understand the risks, and they can’t afford to make their websites vulnerable.

Risks of Downloading BackupBuddy Nulled

As you will see below, the risks of downloading BackupBuddy nulled are many. That is why you should always stick to the premium version. The last thing you want is to use a backup plugin that is effective and secure.

Harmful Altered Code

A nulled version of BackupBuddy may work just fine on the surface. However, it will be unknown whether the redistributed version has been altered with malicious code.

The extent of damage the malicious code can inflict is unknown, and the timing is random. Additionally, you’ll never truly be sure that your backups are working and recoverable.

Poor User Experience

Premium plugins are expected to perform at a high-performance level to justify their price. A nulled plugin has no guarantees of their performance or effectiveness.

Mentioned earlier, a nulled plugin may have various code added that may relay information away from your website, using cryptomining scripts, or other code that can slow down a user’s browser or computer. In general, if a nulled plugin is affecting the user’s experience, they will leave your website, and you’ve built no trust.

Motivation Behind Nulled Plugins and Themes

Individuals who redistribute and alter the code of a plugin or theme have various reasons for doing so. Rarely is it just out of curiosity or recreation. Suspicious coders are looking to profit with one or more of the following strategies even when you download BackupBuddy nulled:

  Ransomware

Ransomware is when a suspicious person has gained entry in your computer or system and encrypts your data, preventing you from using it. In order get access to your data, you’ll need to pay a ransom for the encryption key using a cryptocurrency where it is difficult to trace the recipient.

Ransomware has become a popular hacking scheme as it can render a business or even a government useless without their data.

  Cryptomining

Bitcoin, Ethereum, and various other cryptocurrencies have arisen in the last decade. In order to get more of these cryptocurrencies, they need to be mined using computation cycles. A nulled plugin may contain the script necessary to run this code on the website’s server or your users’ browsers. This can slow down the website’s experience and reduce the trust in your website.

  Data theft

There may not be anything wrong with your website that you can find. Doesn’t mean there isn’t something peculiar happening.

A nulled plugin like BackupBuddy can have code that is sending data to another source. This could be information about your traffic, your users, and purchase information if you run a subscription or ecommerce website.

  Black-hat SEO

I’ve touted many times that SEO is a long-term strategy requiring time and effort to see success. Imagine that your hard work climbing the rankings is all of naught because a nulled plugin is injecting links to low-quality website in your code. It can take months for it to become obvious to you. By that time, your rankings have plummeted, your traffic drops, and your hard-work, time, and efforts have been compromised.

Risk to business

It takes years to build strong reliable business website or blog, and trust and reliability are central to maintaining user loyalty. A simple malicious code embedded in a pirated BackupBuddy plugin can end up causing serious privacy issues to your website. If your website’s sensitive information such as usernames, passwords, and personally identifiable information (PII) is leaked, your business is liable.

No support

Submitting support tickets and requests is a typical feature of a premium plugin or theme. Well, with BackupBuddy nulled version, you don’t have a chance to experience any of that. You are simply on your own with your website. This means that there is no one to answer your queries and provide you with solutions.

Just because you have a backup, doesn’t mean the recovery will go smoothly. When recovering your website, if something goes wrong, your nulled BackupBuddy copy guarantees you no support.

You should also know that even professional premium BackupBuddy users tend to turn to the support feature in case of anything. A simple support ticket can save your business valuable time and money.

No automatic updates

Developers update their plugins and themes on a regular basis to introduce new features, correct security vulnerabilities, and fix bugs. BackupBuddy is fanatically updated with both large and minor updates, sometimes several times a week.

If you are using the nulled BackupBuddy version, you will not receive these imperative updates. Instead, you’ll have to consistently search for an updated version of the plugin, which cuts into your day-to-day business.

Why you should purchase a BackupBuddy License

iThemes BackupBuddy LogoYou’ve spent countless hours and money on your website. To have any downtime or allow it to become vulnerable to malicious individuals will be devastating to your business or blog.

A backup and recovery plan is imperative to ensuring your website is capable of recovering from any issue that you may face. I’ve used BackupBuddy countless times to save a website from a disaster, or migrate a website from one web host to another.

Business and Website Continuity

There are millions of businesses that rely on their company website for them to run smoothly. This means they cannot afford to have any single aspect jeopardizing their online existence.

A backup plugin is imperative to a WordPress website, and a backup and recovery plan.

Peace of mind that the software is safe

Peace of mind about your website’s longevity is worth its weight in gold. Keeping your website lean and mean can help reduce your server’s workload and using an officially released version of a plugin ensures your website will run smoothly.

Without the stress, you can spend more time to expand your business instead eliminating a potential threat. This shows how vital a premium BackupBuddy plugin is and why purchasing it is a decision you will never regret doing.

Peace of mind that your website is safe and recoverable

It’s one thing to have a backup of your website, it’s another thing being able to recover the data. BackupBuddy allows you to fully recover from a previous full website backup, database-only backup, or individual files.

That level of flexibility is among the many reasons why BackupBuddy is trusted by users all over the world. You will not only have at the back of your mind that website is safe, but you will be guaranteed that your backup files are available.

Continuous and automatic updates

With technology constantly evolving, your WordPress website is doing the same. The best way to initialize these changes is through updates. WordPress ensures that continuous updates are made on every BackupBuddy premium plugin. This is a way of advancing the plugin’s capabilities so that it can remain relevant. Such updates also involve bug fixes and strengthening security. You are also sure that the plugin is becoming useful as days go by.

Offsite backup solutions

What makes BackupBuddy premium version a very useful plugin is that it offers you numerous backup options. The plugin comes with a feature that to send your backups to an off-site destination, such as another FTP server, email, Amazon S3, Dropbox, Google Drive, or iThemes’ own BackupBuddy Stash account. will see to it that your files are kept safe.

No matter how experienced the hacker is they will just be limited to the website since accessing files backed up to another site may be quite hard.

BackupBuddy Stash

iThemes offers BackupBuddy users 1GB of Stash storage, which is another destination to store your backups. 1GB is plenty for database-only storage or backups for smaller website.

Larger plans are available for an upgrade.

BackupBuddy support

BackupBuddy premium version features support to help you solve numerous issues or questions when they occur. Through the help center, you can contact the BackupBuddy help team.

Supporting the Developers

The features of premium plugins like BackupBuddy are impressive because the of the hard work the developers have placed into the plugin. Without a steady revenue, BackupBuddy cannot evolve to increase the efficiency of their backups, fix bugs, or ensure the plugin is secure.

Get other iThemes plugins

iThemes Plugin SuiteCombining BackupBuddy with the iThemes Plugin Suite can increase your website’s security and extend your website’s marketing capabilities.

iThemes Security is another plugin that I swear by. It’s an easy-to-use WordPress security plugin that hardens your WordPress website from various threats.

The DisplayBuddy series of plugins offer marketing and theme capabilities such as notification pop-ups, slideshows, carousels, and other marketing features.

Don’t Download BackupBuddy Nulled

The evidence is clear: using a nulled plugin as a poor choice. Using a freely downloaded BackupBuddy nulled version on your website is not a strong or reliable backup and security plan.

Do not place your hardwork or your loyal customers at risk with a nulled plugin. Purchase the real BackupBuddy plugin from iThemes.

Filed Under: WordPress Tagged With: backup plugins, backupbuddy, ithemes, nulled plugins, website security

How to Add Google Analytics to WordPress

July 18, 2019 by Aaron Weiss

Adding Google Analytics to WordPress can be as easy as installing and configuring a plugin, as efficient as customizing a theme, or as performance and scalable option using Google Tag Manager.WordPress continues to be one of the most recognized content management systems for website owners thanks to it’s easy-to-use publishing features, extensibility, and low-entry costs. Now that you have a WordPress website running, it’s time to know:

  • How visitors are accessing your website
  • Where are they are located
  • Who they may be, and their interests
  • What they are viewing
  • Why they might be visiting your website
  • As well as many other metrics and data that can help you learn about your website’s traffic

It doesn’t matter why you’re using WordPress, the next step is to know how well your traffic is working for you and how to create narratives to make it work better. Google Analytic has becoming the industry standard for website analytics thanks to it’s entry-level features, broad data aquisition, and simple user experience.

Table of Contents

  • What is Google Analytics?
  • Create and Setup your Google Analytics Account
    • Create a Google Account
    • Create a Google Analytics Account
  • Installing Google Analytics on WordPress
    • Installing Google Analytics with a WordPress Plugin
    • Installing Google Analytics without a WordPress Plugin
    • Installing Google Analytics with Google Tag Manager and WordPress
  • Create a Privacy Policy
  • Testing Google Analytics and Google Tag Manager
  • Conclusion

There are many choices on how to add this popular and robust website analytics platform to your WordPress website, and the option you choose is dependent on your skill level, time, and interest in performance.

This article will provide insight on what Google Analytics is, the options to install it on your WordPress website, and how to let your visitors know how Google Analytics is capturing their information for transparency.

This article will not discuss:

  • eCommerce tracking
  • Understanding Google Analytics metrics
  • Full Google Analytics account optimization
  • Other Google Product Integration

These areas will be written at a different time, or are already discussed in other articles on this website.

What is Google Analytics?

Google Analytics is the most widely-used website analytics tool for websites, not just for WordPress. The platform can track website sessions, duration, page visits, and various other metrics. Individually, these metrics can provide some understanding of what’s going on, but other metrics and reporting can be combined to create narratives that help you understand what is really occurring on your website.

The most popular aspect of Google Analytics is that it is free. Yep. Doesn’t cost you a penny. There is a paid version, but for 99% of users, the free version has all the features you’ll ever need, and even features you’ll never use.

The robust features and reporting of Google Analytics can get you lost in the weeds when you see how much the service can accumulate and display data.

Google Analytics also has what is called an application programming interface (API). For day-to-day business owners and website administrators, an API isn’t necessary to understand or use Google Analytics. However, programmers can use Google Analytics’s API to connect to other services, and you may find yourself being introduced to another service or program that allows you to connect your Google Analytics account, properties, and views to combine these services with third-party applications.

Where did Google Analytics Come From?

I believe context is important. Google Analytics was purchased by Google in 2005 from a company called Urchin. Google has expanded their platform since then and it continues to be a free service that has conquered the analytics world.

Create and Setup your Google Analytics Account

1. Create a Google Account

The first this to do is to create a Google Account if you do not have one. Gmail is a popular service from Google and is among the most popular ways to use Google’s vast array of products and services. This would count as a Google account. However, you are not required to have a Gmail account or email address. If you have an email address that you’d prefer to use with Google’s products and services, that’s fine too.

Go to https://accounts.google.com/signup and either create your free Gmail account or use the email address you prefer. If you need help, check out this video:

Creating a Google Account Video

Note: There is no sound.

2. Create a Google Analytics Account

Once you’ve created a Google Account, now you’ll need to create a Google Analytics account. Go to https://analytics.google.com/analytics/web/ when logged in with your Google Account, and complete the steps. Here’s a video showing how it’s done:

Creating a Google Analyitcs Account Video

Note: There is no sound.

Account & Property Setup

You’ll be asked to enter the following:

  • Account Name: This can be generally anything you want.
  • Website Name: This will be the name of the first property in your Account. Typically, adding the domain name or website URL is the best option for single websites or first-time users.
  • Website URL: This will be your website’s URL. Be sure to select between https and http, and then enter your website’s URL. If your website doesn’t use www, do not add it.
  • Industry Category: Select the category that best resembles your website. This helps with benchmarking.
  • Reporting Time Zone: What time zone are you in?
  • Data Sharing: These are options to share your Google Analytics data within Google’s broader services. Typically, selecting “Google products & services” and “Benchmarking” is just fine.
  • Click on “Get Tracking ID”.

Agree to Terms of Service

You’ll then be taken to a few Terms of Agreement Pages. It is recommended to read and understand these agreements to understand what information Google tracks.

Tracking ID

You’ll then be taken to the Tracking Code page of your Google Analytics account. You’ll always have an opportunity to re-visit this page. You’ll be given a Universal Analytics ID (UA) that starts with UA-. You’ll also see some HTML code that needs to be added ideally between the <head></head> HTML code on every page of your website that you want to track. Don’t worry, we’ll get to adding this later.

Brief Overview of your Google Analytics Account

Creating an account will automatically create an Account, Property, and an All Web Site Data View. Here are the differences between an Account, Property, and View:

  • Accounts have high-level management of settings, users, filters, and can view change history.
  • Property(ies) allow you to house multiple websites under the account. Each website is considered a property. Under a website’s property, there are options to adjust broader aspects of the analytics code for the website. Consider your website a property.
  • Views allow you to adjust how your property captures data. In most cases, you’ll want to have a few different views. This will allow you to filter out various IP addresses, hostnames, and other traffic, manage your content and channel settings, among other options that help you report, manage, and display data.

Creating a new View

As stated above, your first and only view when you start a Google Analytics account is the All Web Site Data view.In this instance, we’re going to create one extra view. We’ll call this “Filtered” and we’ll filter out our current IP Address. This way, we will not collect information when we visit or our website.

More on Filters

Filters allow you filter out various types of traffic. In the following steps, we only be filtering your personal IP address. You can exclude traffic from internet service providers, subdirectories, or even specific hostnames. This will be handy later on if you use other services that crawl or access your website.

Create a new View.

Create a New View
Click here to enlarge

Use these settings to start:

  • Reporting View Name: Filtered
  • Reporting Time Zone: Choose your time zone
  • Click “Create View.”
New View Settings
Click here to enlarge

Adjust the View settings to ensure we’re filtering out known bots.

  • Bot Filtering: Enabled
  • Save.
Additional View Settings
Click here to enlarge

Before we setup our first filter, we need to know what our IP address is. Go to Google and type in “What’s my IP address”

What's My IP Address
Click here to enlarge

Come back to Google Analytics, and select Filters, then click on “Add Filter.”

Adding a Filter to a View
Click here to enlarge

Now you will enter the following:

  • Select “Create new Filter.”
  • Filter Name: IP Address
  • Filter Type: Predefined
    • Exclude
    • traffic from the IP addresses
    • that are equal to
  • Enter your IP address that you found on Google from one of the previous steps.
Add Filter to View
Click here to enlarge

Now, you’ll be able to browse your own WordPress website without Google Analytics capturing your visits as traffic.
We’ll come back to optimizing your Google Analytics account, properties, and views later in another article.

Installing Google Analytics on WordPress

There are many ways to install Google Analytics on your WordPress website. With so many options, there are various pros and cons. We’ll show three ways to add Google Analytics to your website; with a plugin, within your WordPress theme, and with Google Tag Manager, which can also be added within a plugin or theme.

Installing Google Analytics with a WordPress Plugin

There are no shortages for Google Analytics WordPress plugins available, and the competition is tight. Plugins are perfect for entry-level users who just need the basic setups. Below are a few of the most popular Google Analytics plugins for WordPress.As the comparison table shows above, among the pros of using a plugin is that they are east to install and basic functionality is free, with upgrade options to open a vast array of options.

Among the cons is that it’s another plugin that you’re introducing to your website, potentially slowing it down, increasing security vulnerabilities, may break or be incompatible with other plugins, or break functionality upon upgrade.

Pros and Cons of using Plugins

ProsCons
Easy to installAnother plugin, might slow down your site
Vast array of optionsNeeds to be updated
Free and Premium optionsSome options require premium purchases
Security implications
May break with updates
Caution: One common feature among the below plugins is they allow you to display Google Analytics data within WordPress. While these features might be helpful to some, the additional amount of processing this requires from your host may bog-down your website’s speed and performance. I recommend not using dashboard features and visiting Google Analytics directly to view your traffic data.

Most Popular Google Analytics WordPress Plugins

Google Analytics Dashboard Plugin for WordPress by MonsterInsights

This plugin was originally a Yoast product – the same company that brings you the popular Yoast SEO WordPress Plugin. A few years ago, the plugin was sold to MonsterInsights the same team behind WPBeginner.

Since then, the plugin’s more advanced features have been split between a free and paid version. The free version provides plenty of opportunities for intermediate tracking with Google Analytics. However, the paid versions are stupidly over-priced and don’t provide the level of services expected at that price point.

At the end of the day, this plugin does the job just fine.

Google Analytics Dashboard for WP by ExactMetrics

This Google Analytics WordPress plugin is also also by the same company behind WPBeginner and MonsterInsights is this plugin. Yep, this plugin was acquired by Syed Balkhi in May 2018. It’s strange that a company would choose to acquire two separate Google Analytics WordPress plugins, essentially cornering Google Analytics WordPress plugin market. In hindsight, it’s not a good idea for a free plugin that provides the same features that MonsterInsights is offering a exorbitant prices to run amok.

At this time (July 2019), this plugin continues to provide a robust set of features that the MonsterInsights version only offers but at no charge. However, be prepared for this plugin to either be merged into the aforementioned MonsterInsights version or having more advanced features placed under a premium version. Get it before it’s locked down.

The Rest

The remaining Google Analytics plugins for WordPress offer more or less of the same thing, and there are tons of choices. Unfortunately, to have full control over how Google Analytics is installed and setup on your WordPress website requires a premium or professional version of a plugin.

Installing Google Analytics without a WordPress Plugin

If you’re looking to reduce your server’s load with one less plugin and you feel comfortable with adding Google Analytics to your WordPress website at your theme’s template level, this method is your best bet.There are two additional options in this situation. You can add the code provided in the Tracking Code section of Google Analytics to your header.php file the safer option, or to your functions.php file the cleanest option.

Pros and Cons of using a Theme

ProsCons
FreeRequires some comfort with working with code
Learn to work with theme filesMight be over-written with theme updates
Some themes provide native supportSome options require premium purchases
Caution: Regardless of either method, it is imperative that you understand that either of these methods is advanced and that you should backup your WordPress with the backup method you feel is the best option, and that you can recover a backup if something goes wrong. Read the blog post “You Need a Backup and Disaster Recovery Plan” to understand the importance of backing up your website and knowing how to recover.
Theme Options

Your WordPress theme may offer an area where you can either add your Google Analytics code, or just the UA code. The only downside to this method is it doesn’t give you an option to place the code exactly where you may want it to go, or their code implementation isn’t fully compatible.

Google Analytics Code in header.php

This method is the safest option and will allow you install the Google Analytics code directly between the <head> </head> HTML elements, which is where Google Analytics prefers for it to be installed.

Simply navigate from your WordPress Dashboard to Appearance > Themes > Editor, and then find the header.php file and click on it. In there, somewhere before the </head> HTML element, you can copy and paste the Google Analytics code provided in the Tracking Code page in Google Analytics. Save and test. It will look something like this:

Boom. You’re done.

Google Analytics Code in a WordPress Theme’s functions.php

This option can be a little riskier, and is the preferred method if you want a really slick, performance-focused website. However, if you miss something you’ll get the infamous WordPress white screen of death. I recommend making a backup of this file, or your entire website for that matter, and be ready to move the backup functions.php file to your server in case your experience an issue.

Using this route essentially creates a new action that places the code on the page in a specific spot. The benefit to this method is that you can move this action around as you need to in case other scripts or code needs to be added before or after it.

Simply navigate from your WordPress Dashboard to Appearance > Themes > Editor, and then find the functions.php file and click on it. At the very bottom of this file enter the following code and replace the UA code with your own unique UA code.

Installing Google Analytics with Google Tag Manager and WordPress

The previous methods work well. However, there’s another advanced option that might benefit you if you plan on expanding the amount of scripts that appear on your website, such as Facebook Pixel or other marketing and tracking codes.The biggest benefit to this option is that when you need to install more tracking code on your website, you don’t need to install that code using a plugin or in your WordPress theme’s template files, which as stated earlier, is risky.

Instead of adding just Google Analytics code, you’ll add Google Tag Manager code. Google Tag Manager allows you to create various containers that contain scripts or code that can be executed based on various triggers. Additionally, the Tag Manager code loads asynchronously, which means it loads in parallel to your website’s other requests. If you installed multiple tracking codes directly on your website, each script would be loaded one-by-one, slowing down your site’s loading time.

Pros and Cons of Google Tag Manager

ProsCons
FreeNeed to add as a plugin or in a theme
Install other tracking scriptsCan be complicated
Lightweight and fast
Use the same Google Account

Unlike Google Analytics, Google Tag Manager has two sets of code that needs to be added to your website. Once set will be added within the <head></head> HTML elements, and another set right after the open of the <body> element. This means you’ll need to edit two WordPress theme files, or just your functions.php file.

Create a Google Tag Manager Account & Publish Your First Container

When you first visit Google Tag Manager, click on “Create Account”.

Create a Google Tag Manager Account
Click here to enlarge

On the new account setup page, you will enter in your:

  • Account Name
  • Select your Country
  • Container Name
  • Choose “Web”
  • Click “Create”
Setup your Google Tag Manager Account
Click here to enlarge

You’ll now be presented with two sets of code. The first will be added between the <head></head> HTML elements and sections on your WordPress website. Please see the code below to learn how to install that code on your website.

Google Tag Manager Code and Installation Instructions
Click here to enlarge

Next, you’ll create a “New Tag.”

Create a new Google Tag Manager Tag
Click here to enlarge

You will choose a Tag Type. In this instance, you’ll select, “Google Analytics – Universal Analytics.”

Choose Google Analytics Predefined tag type in Google Tag Manager
Click here to enlarge

Now, you will change the name of the Tag to “Google Analytics”, and click on the Tag Configuration edit button.

New Tag Setup
Click here to enlarge

With the Tag Type already selected, you can use these settings:

  • Track Type: Page View
  • Enable ovverriding settings in this tag
  • Enter your Google Analytics Tracking ID Code. Remember, this starts with the UA-

You’re welcome to review other settings and adjust to your needs.

Tag Manager Tag Configuration
Click here to enlarge

Next, you will choose to add a new Trigger.

Create a New Trigger
Click here to enlarge

Because you selected Google Analytics earlier, a trigger named “All Pages” with a Type of “Page View” is avaialble for you to select. Go ahead and select it.

Choose all page triggers in Google Tag Manager
Click here to enlarge

Save the New Tag.

Save Tag in Tag Manager
Click here to enlarge

Submit your Workspace. and add optional description.

Submit Workspace Update
Click here to enlarge

Write an optional, informative description about your workspace and version. Then click “Publish”.

Google Tag Manager Submit Workspace for Publish
Click here to enlarge

Last, you’ll be presented with a result page of your publish.

Google Tag Manager Publish Results
Click here to enlarge

Google Tag Manager Code in functions.php

Next, we’ll install the code. Again, we’re presented with the option of adding this code with a WordPress plugin, or in theme files. However, for simplicity, we’ll simply use a functions.php file.

Enter the code below in your functions.php file and replace the XXXXXX with your GTM– code in both places.

It’s better to use this code which tells WordPress to place the necessary code in both places, rather than edit two files.

Save and Test.

Create a Privacy Policy Page on WordPress

You might thing that we’re done, but to be fully transparent, comply with most government regulations, and even Google Analytics’s terms of service, you need to let your visitors know that you are using this service which collects data from your visitors in a Privacy Policy page.

If you’ve installed WordPress recently, you’ll automatically have a Privacy Policy page created to help you get started. Feel free to review my own Privacy Policy page and copy and adjust that information to your needs.

Testing Google Analytics and Google Tag Manager with Google Tag Assistant

Other than checking your website’s source (usually Ctrl + C on Windows, Command + U on Mac, or right-click and “view source” on most browsers), you can also install Google’s Tag Assistant on Chrome.

This browser extension helps you check to see if a particular Google services’ code is installed correctly on your website or any website for that matter. Not only does this work with Tag Manager and Google Analytics, it also works with Google Ads too.

Enjoy Google Analytics on Your WordPress Website

It’s all over! You did it!

Now go forth and create great content on your website and share it with the world. You’ll start seeing data appear in your Google Analytics account soon.

Next, learn how you can either optimize your Google Analytics settings for more accurate data capture and what your Google Analytics data means and how to take action.

Filed Under: Film & Television, Google Analytics, WordPress Tagged With: google analytics, google tag manager, plugins, themes, wordpress

Primary Sidebar

Recent Posts

  • TrueNAS Virtual Machine with Ubuntu 18.04 Halting with Signal 11
  • Proxmox ZFS Disk Replacement and Drive Expansion
  • How To Create ZFS Backups in Proxmox
  • Multiple UPS on the same NUT-Server
  • Learning Graylog for Fun and Profit

Categories

  • Film & Television
  • Google Analytics
  • Guitar
  • Lifestyle
  • Projects
  • Proxmox
  • Search Engine Optimization
  • Technology
  • TrueNAS
  • Uncategorized
  • Website Administration
  • WordPress
  • Home
  • Blog
  • About Aaron Weiss
  • Contact
  • Privacy Policy
  • Affiliate Disclosure

© Aaron Weiss. Built with WordPress using the Genesis Framework. Hosted on a2 Hosting and DigitalOcean. Aaron Weiss's LinkedIn Profile