Measure Page Scrolling in Google Analytics

scroll-depth

A Google Analytics plugin for measuring page scrolling

Earlier today I came across a Google Analytics plugin called Scroll Depth, developed by Rob Flaherty. Here’s how he describes Scroll Depth:

Scroll Depth is a small Google Analytics plugin that allows you to measure how far down the page your users are scrolling. It monitors the 25%, 50%, 75%, and 100% scroll points, sending a Google Analytics Event at each one.

You can also track when specific elements on the page are scrolled into view. On a blog, for example, you could send a Scroll Depth event whenever the user reaches the end of a post.

The plugin supports Universal Analytics, Classic Google Analytics, and Google Tag Manager.

Scroll Depth is available on GitHub and on it’s project page. Getting it setup is easy, the only two requirements are Google Analytics and jQuery.

Below is a basic setup.

Just be sure to include jquery.scrolldepth.min.js and the call to .scrollDepth() is made after Google Analytics has been loaded up.

There’s a number of options you can pass, too:. I especially like the elements option. It allows you to define a unique element to record scroll events for. So, if you want to track when users scroll to the footer of a post in WordPress, you could easily set that up!

As stated, the only requirements are Google Analytics and jQuery. If it doesn’t seem to be working for you, ensure that Scroll Depth isn’t being loaded before your Google Analytics tracking code.

Use Google Font Directory Fonts in WordPress

Google has some seriously nice looking fonts available for you to use for free in the Google Font Directory. All the fonts are under an open source license and are served right from Google servers.

Most modern web browsers support webfonts. The Google Font API FAQ would be a good place to visit if you have questions or are curious about some of the limitations.

Making use of these fonts in your WordPress theme is extremely easy, as long as you have a basic understanding of CSS. Now let’s get down to using these in your WordPress theme, we’ll keep it short and simple.

First, head over to the Google Font Directory and pick a font to use. I’ll be using IM Fell as an example, since that’s the font I use for post titles on this site.

Once you find a font you like, click on it. If the font you chose has variants, you will need to click on a variant to use. Once you’re on the font page, click the “Get the code” tab and google will generate the code for the font. You will embed this code in the header.php file for your theme. I usually put it right before the line that calls the theme stylesheet file. Here’s the code I used to include the IM Fell font:

After that, all you have to do is use the font in your CSS, typically the style.css file in your WordPress theme directory. To get my post titles to use the IM Fell font, I did this:

The font-size property defines what size of font to use (duh!). The font-weight property defines the thickness of the font (degree of boldness). You can apply the font-family property using the Google Font to pretty much any piece of CSS that targets text. You can use it for post content, links, widget titles, or whatever you want really.

If you have any questions, feel free to leave a comment and I’ll do my best to help you out!

Use Google Hosted jQuery in WordPress

So, I recently needed to use a google hosted version of jquery for a WordPress theme (don’t ask). I came across this topic at the WordPress forums.

User bazil749 suggested doing this, I’ve updated it to include jQuery 1.4.4:

I added that piece of code to the proper place in the header.php file for the theme and it worked like a champ. jQuery was now loading from Google. The Use Google Libraries plugin does the same basic thing, except it can use libraries other than just jQuery, like jQuery UI, Dojo, MooTools, and Protoype.

There are a number of good reasons to let Google host jQuery for you.