I’m looking for an affiliate program of sorts, but much simpler: I just need to be able to give business associates a link of their own and it passes a variable along to a hidden field in the form when it’s submitted so that we can tell who referred the visitor. (Or if anybody knows a better way...)
Some sort of basic stats system for the affiliate would be nice, but we’re really just concerned with tracking.
If anybody has any advice, I would greatly appreciate it.
-
☆ A M B ☆
- 24,524 Posts
You can add the $_SERVER values to eForm’s fields, then do whatever you want with them. I’m using this one to get the SERVER variables so I can use them in my report chunk. You could use them in another eForm event snippet like eform2db.
<?php
function getServer( &$fields ){
// remote_addr
$fields['remote_addr']=$_SERVER['REMOTE_ADDR'];
$fields['remote_host']=$_SERVER['REMOTE_HOST'];
$fields['user_agent']=$_SERVER['HTTP_USER_AGENT'];
//return succes
return true;
}
?>
This is what my contact form document has:
[!getServer!]
[!checkField!]
[!eForm? &formid=`ContactForm` &tpl=`ContactForm` &report=`ContactReport` &subject=`sottwell.com Contact` &thankyou=`ThankYou` &replyto=`email` &debug=`1` &eformOnBeforeMailSent=`getServer` &eformOnValidate=`checkField`!]
I use the checkField function for spam-proofing using an empty field that must stay empty. It’s moved off the screen with CSS, but spam-bots see the source and will fill it in, causing eform to quietly fail.
Actually, I figured out a VERY easy way to do this... I just setup a subdomain for the person who will be sending traffic, and it points to the root of the site. Then in a hidden field on the form, I can insert:
<?php
echo $_SERVER[’SERVER_NAME’];
?>
Then the form will tell us what subdomain the submission was sent from.
The only problem with this in ModX is that the base href messes it up... but I fixed that by putting the same snippet in there so that the base href also uses the subdomain instead of the url defined in ModX. Not sure if this will mess anything up, but it seems to be working fine.