Viewing 2 replies - 1 through 2 (of 2 total)
  • Sounds like a job for Google Analytics.

    Thread Starter madguy000

    (@madguy000)

    The use case is as follows –

    1. Forms are on one specific page
    2. All other pages have a link to that page so that visitors can fill the form.

    I thought that it would be a good idea in this case to find out what was the previous page, in this case.

    I browsed thru the forum and found a post where a user had used php to find out the url of the post where the form is located. I’m unable to find that page now, can someone please link to that so that the person is attributed?

    The code below will enable you to put a hidden field on the form to capture the referrer value, and use another custom shortcode in the mail to populate the referrer value. Here is my code: (edit functions.php)

    function hiddenreferer_shortcode($tag) {
    
    	if ( ! is_array( $tag ) )
    		return '';
    
    	$options = (array) $tag['options'];
    	foreach ( $options as $option ) {
    		if ( preg_match( '%^name:([-0-9a-zA-Z_]+)$%', $option, $matches ) ) {
    			$name_att = $matches[1];
    		}
    	}
    
         $html='';
    	 $referer = $_SERVER['HTTP_REFERER'];
    	 if ($referer){
    		$html = '<input type="hidden" name="' . $name_att . '" value="'.$referer.'" />';
    	 }
    	 return $html;
    }
    wpcf7_add_shortcode('hiddenreferer', 'hiddenreferer_shortcode', true);
    //use [hiddenreferer referer name:referer] in the form
    //and [referer] in the email template
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Contact Form 7] Need to know which page the user came from to fill the form’ is closed to new replies.