After creating two filter functions that append text to the existing content, this recipe shows you how to modify the page content before it is displayed on the screen. More specifically, the following plugin will expand on the Google Analytics header plugin created earlier and add a JavaScript function to all the links that are included in posts and pages to track when they are clicked by visitors.
You should have already followed the Adding output content to page headers using plugin actions recipe to have a starting point for this recipe and the resulting plugin should be active in your development site. Alternatively, you can download the resulting code (Chapter 2/ch2-page-header-output/ch2-page-header-output.php
) for that recipe from the Packt Publishing website (https://www.packtpub.com/support).