Last Updated on September 21, 2023 by Christopher G Mendla
I wanted to get two things when users submitted a form to one of our Joomla sites using forms created with Fabrik: (1) The page they were on when they submitted the form and (2) the user agent.
I wanted the page they were on when they submitted the form because we have the contact form on every page. It would be helpful to see which page the user was on when they filled it out and hit submit.
I wanted the user agent because Google analytics was showing that users on phones accounted for about 51 percent of our visitors. I wanted to see if that correlated with the form submissions.
Now, Google analytics will provide some of this info but it is a bit difficult to sort through plus I wanted confirmation.
We are using the release of Fabric Current as of Feb 2014 on Joomla 2.5.
In order to make this work you need to set up a pair of elements for the form and you need to set up a custom email form.
To set up the elements, you need to create elements (Fields) for pageurl and useragent.
You need to create an element for each.
- pluin – field
- Hidden – yes
- eval-yes
$pageURL = ‘http’;
if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER[“SERVER_PORT”] != “80”) {
$pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”];
} else {
$pageURL .= $_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI”];
}
return $pageURL;
For the User agent, the default box is
$useragent = $_SERVER[“HTTP_USER_AGENT”];
return $useragent;
You need to create a custom email template in /plugins/fabrik_form/email/tmpl. You can call it formname.html.
A typical template looks something like The following. The items in brackets are the element names. Note page and pageurl. You can also get the fabrik referrer and, if you have the ip plugin, the ip of the submitter.
First Name: {firstname}
Last Name: {lastname}
Email: {email}
Phone: {phone}
Pageurl: {pageurl}
———————————————————
Fabrik Referrer: {fabrik_referrer}
User agent: {useragent}
Fabrik Internal ID: {Itemid}
Time-Date: {date_time}
IP: {ip}
The incoming email should look something like
First Name: Christopher
Last Name: Mendla
Email: [email protected]
Phone: 911
Pageurl: http://www.site.com/page-they-were-on
———————————————————
Fabrik Referrer:
User agent: Mozilla/5.0 (Linux; Android 4.4.2; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Safari/537.36
Fabrik Internal ID: 108
Time-Date: 2014-02-22
IP: 999.999.999.999
There you have it.. You’ve set Fabrik to give you the page the user was on and you can see the user agent. IN this case you can see that the user was on an android OS and a Nexus 7 device (A tablet). The ip would be the real ip. This was changed for privacy reasons…