gravy834
Forum Replies Created
-
Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google AnalyticsGlad that you fixed it, got to love a workaround.
Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google AnalyticsIn theory, yes.
The DOM event in the new script ‘wpcf7mailsent’ is the new version of ‘on_sent_ok’ which is being deprecated. Here’s the offcial take on it from CF7: “Note: The method using on_sent_ok hook is no longer recommended. This function is scheduled to be abolished by the end of 2017.” https://contactform7.com/tracking-form-submissions-with-google-analytics/
Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google Analytics@creativekindle
No worries. Let us know what the issue is when you find it.Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google AnalyticsIs the class ‘wpcf7’ on the page at all?
Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google AnalyticsSo add this script as a custom HTML tag in GTM:
<script> var wpcf7Elm = document.querySelector( '.wpcf7' ); wpcf7Elm.addEventListener( 'wpcf7mailsent', function( event ) { dataLayer.push({'event' : 'formSubmitted'}); }, false ); </script>
Then create a tag (whichever type you’re after) that is triggered by the custom event ‘formSubmitted’.
If you have multiple forms then you can use a custom JS variable that identifies the form and then use it as a rule in the trigger too.
function() { var nav = jQuery({{Click Element}}).closest('form').attr('action'); if (nav.includes("#wpcf7-INSERT FORM ACTION-o") == true) { return 'Contact Form'; } else if (nav.includes("#wpcf7-INSERT FORM ACTION-o") == true) { return 'Newsletter Sign Up'; } else{ return 'unknown form'; } }
You can find the form ID by inspecting element on the form and finding the form action value. You just need to include the part that’s between ‘#wpcf7-‘ and ‘-o’. Note, if multiple forms are on the page, the action value will end with o1, o2, o3 etc. In the code above I’ve omitted the number at the end in case it changes depending on the page that the user is on.
I found that the latest version of the CF7 plugin (4.7) has to be in place, it won’t on older versions.
Hope this helps.
- This reply was modified 8 years ago by gravy834.
Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google AnalyticsI ended up using some JS in GTM:
var wpcf7Elm = document.querySelector( ‘.wpcf7’ );
wpcf7Elm.addEventListener( ‘wpcf7mailsent’, function( event ) {
dataLayer.push({‘event’ : ‘formSubmitted’});
}, false );Found it here https://contactform7.com/dom-events/
Forum: Plugins
In reply to: [Contact Form 7] Event Tracking in Google AnalyticsI’m having the exact same issue.
- This reply was modified 8 years ago by gravy834.
Forum: Plugins
In reply to: PayPal Web Payments Pro integrated with WP, is there a plugin?Any ideas anyone?
I really need some urgent help with this.Thanks