Monthly Archives: March 2011

WordPress Google Analytics Content Filter

March 17, 2011

I’ve been working on a site recently that has a lot of PDFs that the content owners link to and I’ve been wanting to track the number of views that each PDF has. To accomplish that I’ve been using a feature of google analytics that requires you to add some extra info to links so you can track how many clicks a PDF gets.

Up until now I’ve been adding that extra information by hand because there haven’t been a lot of links but I figured there was a ripe oppurtunity to do some simple automation. I’ve created the following content filter that will automatically add the google analytics bit to each link in the content, you just have to put it in your theme’s function.php file. I also added a bit that tracks outbound links as well just because that might be handy info to have as well.
(more…)