{ WordPress Analytics Action }

Add GA tracking to a WordPress site without having to install a heavy-duty plugin.

In functions.php (or plugin): (text mode to see JS code)

 

add_action( '__theme_analytics', 'theme_analytics_code', 10 );
function theme_analytics_code() {
  ?>

 

In header.php right after the body tag:

do_action( '__theme_analytics' );