WordPress.org

Forums

Collapse-O-Matic
Tracking Expands with Google Analytics Event Tracking (3 posts)

  1. sackerman
    Member
    Posted 3 years ago #

    Hi everybody, I'm wondering if its possible (and if so, how to) to track expands with the "Event Tracking" feature built into Google Analytics.

    Any insights?

    Thanks!!!!

    http://wordpress.org/extend/plugins/jquery-collapse-o-matic/

  2. WStringer2
    Member
    Posted 3 years ago #

    Hi sackerman...funny you should ask, this is something I just got working this morning.

    There may be a better way, but here's how I did it:

    • Add an ID to the "Read More" image:
      [expand title="<img id='readMoreImg' src='imgs/read-more.jpg' />" trigclass="noarrow" tag="div"]
    • Add some jQuery (after the [/expand] tag) that will add an "onClick" event to the image.
    • Set up the onClick event to call the GA event tracking, then return true (so Collapse-O-Matic will keep working after the event is called)
    • So my jQuery looks something like this:

      <script type="text/javascript">
      	jQuery("#readMoreImg").attr("onClick", "_gaq.push(['_trackEvent', 'ReadMore', 'Clicked', 'Event Title Goes Here']);return true");
      </script>

      Hope this helps!

  3. sackerman
    Member
    Posted 3 years ago #

    Looks like it may do the trick!
    Thanks a ton WStringer2, i'll post back with my findings!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Collapse-O-Matic
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic