• Resolved robertcroydon

    (@robertcroydon)


    Hi – looking to use Forminator on vinyl-wanted.com. We display 2 different email addresses based on whether there is a GCLID (ie comes from Google Adwords). We would like the form submission to also do the same, so if there is a GCLID it is sent to [email protected] and if not then sent to [email protected].

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @robertcroydon

    Hope you are doing fine!

    There is a feature in Forminator that can help with this request. Fields can be pro-populated with values coming from a query string, which is the case for GCLID.

    Please check our documentation to get more info about the configuration you need to perform:

    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#pre-populate-form-field-values

    Basically, you need to set a hidden field and pre-populate it with the GCLID variable. Then you can create a condition based on the hidden value to send the email notification to a different email address (condition could be used to check if the hidden field is pre-populated or not). Please find more info about the notification conditions in the link below:

    https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#conditions-tab

    Hope this info is useful.

    Kind regards

    Luis

    Thread Starter robertcroydon

    (@robertcroydon)

    Hi – Thanks. I have added the form to a page (https://vinyl-wanted.com/contact-vinyl-wanted-at-vinyl-wanted-com/?gclid=ABCDE12345) and got a cookie called gclid with a value for example “ABCDE12345” for example. How do I get this value into the query string of the hidden field?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @robertcroydon

    Thank you for response!

    I’m not quite sure if we are on the same side here so let me ask:

    Does the URL always include the ?gclid= part when somebody is accessing the form?

    Or instead I can e.g. access vinyl-wanted.com/?gclid=ABCD, then the cookie is set but when I go to another page (e.g. one with the form) the ?gclid= part is no longer there (and the value is ONLY in cookie)?

    —–

    If it’s the first case then it’s quite simple:

    – add the field of type “hidden” to the form
    – in this field settings select “Query Parameter” option from teh “Default Value (optional)” drop-down list
    – and then in the “Query parameter” field below it put just

    gclid

    This hidden field will then automatically take the value of gclid parameter and you can then use it in e-mail notification settings to recipients using “email routing” in notification configuration.

    If it’s the second case (value is ONLY in the cookie), then it would require additional custom code to read the cookie value first into the hidden field.

    Kind regards,
    Adam

    Thread Starter robertcroydon

    (@robertcroydon)

    Its the second case. I think i can extract the value from the cookie but what is the format for inserting this value into the hidden field? Using a $ or what?

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @robertcroydon

    For this you can use:

    <?php
    
    add_filter( 'forminator_field_hidden_field_value', 'wpmudev_populate_hidden_field_date', 10, 4 );
    
    function wpmudev_populate_hidden_field_date( $value, $saved_value, $field, $hidden_field ) {
    
    	$cookie = htmlspecialchars( $_COOKIE["gclid"] );
    
    	if ( 'custom_value' == $saved_value && !empty($cookie) ) {
    
    		$value = $cookie;
    	}
    
    	return $value;
    }

    Just add the Hidden field > Custom Value and use “custom_value” as a placeholder which can also be used in your conditionals.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @robertcroydon

    Just an update, you can use the code as mu-plugin

    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Best Regards
    Patrick Freitas

    Thread Starter robertcroydon

    (@robertcroydon)

    Hi Patrick – Thanks a lot. That worked. Much appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change email address if GCLID present?’ is closed to new replies.