Last active
December 19, 2015 03:19
-
-
Save crystalw/5889702 to your computer and use it in GitHub Desktop.
Check an element's class to determine the outcome of an event and push the occurrence to Google Analytics.
Useful for tracking successful form submits on Ajax or other form types with static urls. Google Event Tracking Guide: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="outcome" class="successful"> | |
| <p>Thanks, your message has been sent!</p> | |
| </div> | |
| <script> | |
| $(document).ready(function() { | |
| if ($( '#outcome' ).hasClass( "successful" )) { | |
| _gaq.push(['_trackEvent', 'Category', 'Action', 'opt_label']); | |
| } | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment