Last active
March 5, 2017 19:42
-
-
Save jg314/5430f002c7be986d5f9c to your computer and use it in GitHub Desktop.
Google Analytics tracking code for virtual pageviews for Gravity Forms submissions that don't send users to a new page.
This file contains 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
<!-- | |
The js code snippet below should be placed in the confirmation text for a Gravity Form that does not send to a thank you | |
page on submission, such as a sidebar or footer email newsletter signup form. | |
* This snippet will work for forms that submit via both ajax and non-ajax. | |
* This snippet will work with plugins such as Google Analytics for WordPress by MonsterInsights. | |
* This snippet will work for Universal Analytics, but not Classic Analytics. | |
You can read more about tracking pageviews at https://developers.google.com/analytics/devguides/collection/analyticsjs/pages. | |
--> | |
<!-- Make sure to turn off auto-formatting within the Gravity Forms confirmation edit screen --> | |
<script type="text/javascript"> | |
var ga = window[window['GoogleAnalyticsObject'] || 'ga']; | |
if ( typeof ga == 'function' ) { | |
// Change '/newsletter-signup-confirmation/' to a URL that makes sense for your virtual pageview | |
ga( 'send', 'pageview', '/newsletter-signup-confirmation/' ); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment