Inserting Onclick Into previous_post_link and next_post_link (3 posts)

  1. awb9h
    Posted 3 years ago #

    Hey everyone,

    I've started using onclick push data to Google Analytics to get a better idea of how visitors are navigating through my site. It's going great except I've hit a snag tracking clicks on next and previous post links, as I can't figure out how to insert the onclick code into the actual next and previous post links. Does anyone know how to do this?

    For example, I need to insert:

    onclick="_gaq.push(['_trackEvent', 'Next Page']);"

    Into a href="next post", so that it looks like

    a href="next post"onclick="_gaq.push(['_trackEvent', 'Next Page']);"`



  2. wprock
    Posted 3 years ago #

    try this onclick="JavaScript: _gaq.push(['_trackEvent', 'Next Page']);"

  3. awb9h
    Posted 3 years ago #

    Hey Wprock,

    Thanks for the answer, but I realized I wasn't clear. In the previous_post_link and next_post_link functions, it seems like you can only insert text before and after the link, but not in the actual link itself. What I'm trying to figure out is a work around for this.


Topic Closed

This topic has been closed to new replies.

About this Topic