Thanks to the Special Mail Tags provided in Contact Form 7, it is possible to learn much more than just the information directly provided by the user when they submit a form.
Increasingly you want to know more. Details like the date and time of the submission of the form, as well as the browser and IP information of the client, may be useful. This is where the Special Mail TagsMail Tag Mail Tags are used in Contact Form 7 (CF7) (in the Mail Tab) to show information collected from CF7 form fields (in the Form Tab) in emails sent by CF7. come in handy.
In this article, we focus on the type of information these special mail tags can provide, such as:
- Date and time – Date and time of the form submission
- User information – Form users IP address and browser used
- Referee information – Details of the page or post where the form was submitted and its author
- Serial number – Unique serial number for each form submission
By the end of this article, you should be able to utilize these special mail tags to improve the Contact Form 7 emails you receive when users complete your forms.
Before you begin
Before we start, there are a few things that you must know:
- How to set up a CF7 Skins form – Learn more
- A basic understanding of WordPress post meta data (if you want to use post meta data) – Learn more
Regular Mail Tags
In Contact Form 7, you can use various mail tags to automatically send emails. You can assign the form fields with names such as [your-subject]
, [you-email]
, [your-message]
etc. Then, simply use the corresponding tags in the email templateTemplate CF7 Skins Templates are the structure of your form, providing the content and layout. They act as an easy to follow guide that can be adjusted to your particular needs. and the information will be sent in the email. A typical form with email will look something like this:
When do you use Special Mail Tags?
While regular mail tags are often enough for the basic emails, they provide little to no additional information. Depending on the situation, you may want to send additional information with the email such as:
- the date and time of submission of the form
- the location where the user filled in the form
- details of the actual page which the user used to submit the form, if you’re using the same form in several pages
- the details of the author of the page or post where the form was submitted
- a unique serial number for each form submission
Special Mail Tags for date and time
There are two special mail tags – one each for date and time of the submission – that you can use to add this information to the email.
The tag for the date of submission is [_date]
and that for time is [_time]
.
All you have to do to get the date and time of the form submission in the email is add the tags to the email body.
Special Mail Tags for user information
There are two special mail tags that offer additional information regarding the users. One of them provides the IP address while the other provides the user agent details (information like browser and Operating System) of the user.
IP
You can use the [_remote_ip]
tag to include the IP address of the user submitting the form in the email. In the actual email, the sender’s client IP will replace this tag. This may be useful when you need to know the location of the client.
User Agent
You can use the [_user_agent]
tag to include the user agent details of the client. The email will then include the device as well as the browser used by the client, which might be hugely important when doing techical support.
Special Mail Tags for referee information
Another thing that you might want in the email is information regarding the location that the user used to submit the form. This can range from the details of the post which contained the submitted form to the URL of the form itself. You can even get information about the author of the post containing the submitted form.
Form URL
To include the URL of the submitted contact form, you can use the [_url]
special mail tagMail Tag Mail Tags are used in Contact Form 7 (CF7) (in the Mail Tab) to show information collected from CF7 form fields (in the Form Tab) in emails sent by CF7.. This can be very useful if you have all your Contact Form 7 forms submitted to a single email address. Using the URL of the form, you can easily identify which form the user submitted.
Post Details
It is not uncommon to use the same form on several pages. If you have done that as well, you may need a way to know which particular page the form was submitted from. Thanks to the special mail tags, there is a range of page information that you can send with the email on form submission.
Currently, the available tags are [_post_id]
, [_post_name]
, [_post_title]
and [_post_url]
.
Note: The
[_post_name]
tag gives the “slug“ of the post.
Here is an example of these tags in action. You do not need to use all of them at once. You may use any number of the tags as needed.
Author Details
Now, in some cases, you might also want to know the details of the author of the post which contained the submitted form. For instance, feedback or review forms might require such information.
There are two pieces of information regarding the author that you can get from the special mail tags – the name and the email address of the author. You can use the [_post_author]
tag to include the name of the author of the post in the email and the [_post_author_email]
tag for the email.
Special Mail Tag for Serial number
Now, if you’re using just basic forms, all the above information might suffice, but if you have a lot of traffic on your site, you might want some sort of way to keep a track of the count of the submissions. An ideal way to do it would be by using serial numbers.
Note: To use this feature, Flamingo 1.5+ is should be installed on your site.
Using special mail tags, you can make sure you get that serial number in the email. When you use the [_serial_number]
tag in the form, it will be replaced by a number in the email, whose value will automatically increase each time the form is submitted.
Practical Example of using Special Mail Tags
Here is a practical example of how to use these tags together.
- The
[_serial_number]
tag is being used for the form number. - The
[_date]
,[_time]
,[_remote_ip]
and[_user_agent]
tags are used at the top for information about the sent form. - The
[_url]
,[_post_url]
and[_post_title]
tags are used to reference the referee form and posts along with hyperlinks to navigate to them. - The
[_post_author]
and[_post_author_email]
tags are being used to display the author info and for a means to contact the author directly.
Be cautious how you use Special Mail Tags
While the special mail tags provide a number of detailed information for you to use, it is important to only use them in proper conditions. It is up to you to protect the information of the client. Most importantly it is vital that you do not disclose information of users like IP address to any party without the consent of the user.
Further reading
See https://contactform7.com/special-mail-tags/
Now that you know how the special mail tags work in Contact Form 7, use them in your own form.
Not a CF7 Skins user yet? Download it for free.
Prefer to learn via video?
This video briefly demonstrates how to use Special Mail Tags to improve your Contact Form 7 emails.
Have questions or need help?
If you are using the free version of CF7 Skins, you can get in help via the CF7 Skins community and also the Contact Form 7 Support forum.
If you are using any of our Add-ons then we provide Premium Email Support to deal with your questions and problems.