Funny thing happened within the last few days, I was asked by three people, how to add Google Analytics to a Drupal site.
So they do, but that's not how I did it. Maybe it's just confusing the way the instructions were written or maybe new Drupal users don't understand the concept or have the ability to install a module, or whatever, doesn't matter.
For this, we'll just use a block.
Before you start, make sure you have the PHP filter enabled in your modules section, otherwise Step 6 won't make any sense.
- Login to your site.
- Click Administer -> Site Building -> Blocks -> Add Block.
- Give the new block a Block Description of Google Analytics.
- Leave the Title blank, no need for it.
- Paste the code snippet that Google gave you into the Block Body.
- Scroll down, click Save Block
- Login to your site. *Not assuming you're still logged in from step one
- Click Administer -> Site Building -> Blocks.
- In the list of Blocks you should now see Google Analytics listed and the Region set to None.
- Set the Region to be whatever is closest to the footer, some themes have a left/right/center, or whatever footer... just pick one of those
- Scroll down, click Save Blocks
That's it, you're done.
Test it to make sure it's on the page
- Browse to your site.
- View the source of any page.
- Scroll down in the source and look for the snippet of Google code you pasted into the new block.
- If you see it, you should be all set.
Note! If you're thinking, cool, now I'll go to my site and click all around like crazy and login to GA too see all of your new data, you won't. Google Analytics takes about a day or so to start collecting.
As always, hope it helped and comment if you get stuck or have a question.