• Resolved vladblagi

    (@vladblagi)


    Hi,

    There is a number of fields you can collect in a MailChimp form, like
    {response}, {subscriber_count},{language}, etc.

    I would like to be able to collect HTTP_REFERER, e.g. via {referer}.

    If you are like me and cannot wait, here is a small hack that worked for me. In the file includes/functions/template.php, I changed the following two lines:

    $needles = array( '{ip}', '{current_url}', '{date}', '{time}', '{language}');
    	$replacements = array( $_SERVER['REMOTE_ADDR'], mc4wp_get_current_url(), date( "m/d/Y" ), date( "H:i:s" ), $language );

    with

    $needles = array( '{ip}', '{current_url}', '{date}', '{time}', '{language}', '{referer}' );
    	$replacements = array(
    		$_SERVER['REMOTE_ADDR'],
    		mc4wp_get_current_url(),
    		date( "m/d/Y" ),
    		date( "H:i:s" ),
    		$language,
    		$_SERVER['HTTP_REFERER']);

    Best
    Vlad

    https://wordpress.org/plugins/mailchimp-for-wp/

Viewing 1 replies (of 1 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Vlad,

    That’s the right way to do this, I will work on a way to make this more easy without having to overwrite the plugin files.

    Another option is to simply include the {referer} tag in your form and then add the following code snippet to your theme its functions.php file.

    add_filter( 'mc4wp_form_content', 'my_mc4wp_form_content' );
    
    function my_mc4wp_form_content( $content ) {
    	$referer = ( isset( $_SERVER['HTTP_REFERER'] ) ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : '';
    	$content = str_ireplace( '{referer}', $referer, $content );
    	return $content;
    }

    Thanks for sharing!

Viewing 1 replies (of 1 total)
  • The topic ‘Collect HTTP_REFERER in the MailChimp form’ is closed to new replies.