Contact Form 7 Google Analytics
Tags: contact form, contact form 7, cf7, contactform7, google analytics, ga, universal, forms, form, track, tracking, event, events, goal, goals
Donate link: https://cash.me/$AndrewRMinionDesign
Requires at least: 4.3
Tested up to: 5.0.0
Stable tag: 1.8.7
Adds Google Analytics Event Tracking to all Contact Form 7 forms.
Adds Google Analytics Event Tracking to all Contact Form 7 forms sitewide, using “Contact Form” as the Event Category, the Contact Form 7 event as the Event Action, and the form name as the Event Label.
Supports the most popular Google Analytics plugins, including the following:
- Google Analytics by MonsterInsights, formerly “Google Analytics by Yoast”
- Google Analytics Dashboard for WP by Alin Marcu/ExactMetrics
- Google Analytics by Kevin Sylvestre
- Google Analytics by Praveen Chauhan
- Analytics Tracker by Valeriu Tihai
- Enhanced Ecommerce Google Analytics Plugin for WooCommerce by Tatvic
- The default Google Analytics code copied from the Analytics admin panel (both the newer
gtag.jsand the older universal
- Google Tag Manager (using
gtm.js) (see additional setup instructions in the FAQ section)
- Any other plugin using
- To add others, open a pull request
- Install and activate the plugin
- Enable the actions you would like to send (if you skip this step, it will send all available actions).
Frequently Asked Questions
What about GDPR (General Data Protection Regulation)?
This plugin does not collect or send any personal information or form submissions to Google Analytics. The only form-related information sent is the name of the form and the submission result (invalid, spam, mail sent, mail failed, and sent).
Google Analytics does collect more information including, but not limited to, the following:
- Page name, URL, and language
- Screen and window size
- The user’s IP address
For more information, refer to Google’s compliance information.
Please also note that Contact Form 7 and other plugins may collect, process, or store user data.
Where will events show up?
Check your statistics in Google Analytics under Behavior > Events or under Real-Time > Events.
What events will be shown?
This depends on the settings you choose.
- Invalid - Fires when an Ajax form submission has completed successfully, but mail hasn’t been sent because there are fields with invalid input.
- Spam - Fires when an Ajax form submission has completed successfully, but mail hasn’t been sent because a possible spam activity has been detected.
- Mail Sent - Fires when an Ajax form submission has completed successfully, and mail has been sent.
- Mail Failed - Fires when an Ajax form submission has completed successfully, but it has failed in sending mail.
- Sent - Fires when an Ajax form submission has completed successfully, regardless of other incidents.
- This is the only event available if you have Contact Form 7 version 4.7 or earlier.
- This is the only original event sent by this plugin. I recommend enabling the other four and disabling this event, unless you need it for old goals you had set up from several years ago.
How do I set a goal in Google Analytics?
Note: these instructions are provided for reference and may become out of date if Google Analytics changes their feature set or labels.
- Click on “Admin” in your Google Analytics account menubar
- In the right-most column (“View”), click on “Goals”
- Click on the “+ New Goal” button
- Set the Goal description
- Enter a name for the goal (I suggest “Contact Forms”)
- Choose the “Event” radio button and click “Continue”
- Set the Goal details
- Set the “Category Equals to” field to “Contact Form 7”
- Set the “Action Equals to” field to the event you wish to track (see above for a list of events)
- If you want to define goals for specific form, enter the name of your form in the “Label” field
- Click the “Save” button
How do I use this with Google Tag Manager (gtm.js)?
- In your Google Tag Manager workspace, add a new Trigger.
- In your Google Tag Manager workspace, add a new Tag.
- Save and publish your changes.
- Fix typo in old tracking code for GTM.
- Fix typo in upgrade notes.
- Fix a bug with GTM and older CF7 versions.
- Drop “Contact Form” event labels for some integrations, leaving just “Contact Form 7” as the event label.
- Fix a bug sending “Contact Form” instead of “Contact Form 7” as the event label for certain configurations.
- Fix a bug sending the form ID instead of name to Google Analytics.
- Cache form titles and IDs for better performance.
- Remove 1.7.0 admin upgrade notices.
- Fix a bug causing events not to send due to upgrade logic.
- Set default options if user has not selected events to send.
- Add options to enable/disable the available event actions.
- Update readme with goal tracking instructions
- Update readme with GDPR notes
- Update plugin coding standards
- Fix error with undefined constant
- Fix error with admin notice on PHP < 5.0
- Add support for all CF7 DOM events. Please see this note for more detail.
- Add support for PHP < 5.3
- Add support for Google Tag Manager
- Add support for sending the Contact Form 7 form name instead of just the form ID
- Update suppoprt for gtag.js custom events
- Add support for the Global Site Tag (gtag.js)
- Update to use new DOM events in Contact Form 7 v4.8
- Fix JS issue if
- Fix PHP undefined index issue
- Fix issue where any manually-specified items were being deleted
- Add support for Google Analytics by Yoast
- First stable version