Hudson with Alchemy on Demand here. Today I want to talk to you about something that every marketer or small business owner should know how to do, and that’s how to install a bit of code into your website.
This is very useful knowledge, because it gives you familiarity with accessing your hosting files, as well as better knowledge of WordPress, which is great for seo reasons, among others.
I’m going to show you how to do this two different ways.
First, the easy way, this is for all of you who have access to the header section of your site through your wordpress dashboard.
And Second, the slightly more involved way of accessing this information through the control panel of your website’s hosting company.
Ok. So first I’m going to show you the easy way, and to do that we have to 1.) have a wordpress blog, and 2.) access that blog via the WordPress dashboard.
So first, let’s do that. I’m going to navigate to the backend of my site.
Once I’m in the WordPress dashboard I’m going to go to Appearance => Editor and then I’ll be taken to this screen that shows me some of your website’s source files.
**VERY IMPORTANT!** This is very important! If you make any changes to these files things can go very very wrong to your site, so before you ever make any changes at all to any of your website’s files, you should backup your work.
How do you backup your files? It’s really easy. Just copy all the data and paste it into a plain-text editor like “Notepad” or something similar.
Not too bad, eh?
Ok. So now I’m going to look over here on the right hand side of my screen where I can see files in blue that are in this column here under “templates.”
I’m going to navigate to the “Header (header.php)” file and select it.
Now, what WordPress is doing here is letting me access these files that are stored on our host server. It’s a relatively new feature of WordPress designed for those of us who don’t like to get our hands dirty with ftp transfers and accessing our hosting files directly.
Pretty nice, eh? It really helps simplify things.
Ok. So now that I’m in my header.php file, what I’m going to do is, I’m going to look for the <head> tab. Then, when I find it, I’m going to look for the closing head tag, which looks like this: </head>
Now, right before that closing head tag is where I’m going to need to put my google analytics/webmaster tools/yoast seo plugin code, you name it.
Because what these codes do is track user’s activity on your site. So you’re going to need to place this code information on every page of your site.
An easy and non-invasive way is to place that info in the “head” section of your site. Every site has one of these sections, and it’s common practice for wordpress themes to have a “header.php” section which is called on every page of the site.
So, if it’s a piece of code that needs to go onto every page of your site, the header is likely where you’re going to want to place it.
Ok, so now you need your Google Analytics code.
To get that, go to www.google.com/analyics and sign up. There you’ll be given your google analytics code.
You’re going to need to copy (Ctrl + C) and paste (ctrl + V) this snippet of benign code into your header file, right before the </head> tag, like so.
Once your done, just click save changes and voila! You have now successfully installed Google Analytics!
Ok, step two is for those who have to access their header through their hosting provider or ftp.
First, navigate to your hosting’s cpanel.
Then go to File Manager.
From the File Manager, make sure that you’re in the public_html file, then double-click on the appropriate domain name for the website you’re trying to upload the Analytics code to.
Then, since this is a WordPress site, double-click on the wp-content folder, then select the themes folder (double-click that). Then select the theme your WordPress site is currently using, in this case it’s “Vertex,” and then you’ll see a list of files. In that list you should see a header file.
Right click the header file and select “code edit.” Now, before you do any actual editing be sure to backup your work by copy and pasting all the text here into a plain-text editor – something like notepad or Simple Scripts.
Then, like in the Dashboard, you’re going to look for the closing head tag, the tag that looks like this: </head>.
You can find this either by scrolling down or by using the search function (CTRL+F on a PC and Function+F on a Mac) and searching for the </head> tag.
Once you find it, paste your Google Analytics code on a new line directly above the closing head tag.
Save your changes and voila! – That’s how you add the a bit of code to your website!
Thanks for watching!”