Hello !
You can control the data sent to Mautic using the wpmautic_tracking_attributes filter.
In your theme / plugin you can add something like this :
add_filter('wpmautic_tracking_attributes', function($attributes) {
$attributes['new_field'] = 'my value';
return $attributes;
});
You can add, remove or update the generated attributes before they will be sent to Mautic.
-
This reply was modified 7 years, 1 month ago by
shulard.
Thanks for this @shulard
Could you please give a full-blown example of how to add this code? I have a registration form field called Country which I would like to connect to the Country field in Mautic. What would the code look like for this?
-
This reply was modified 7 years ago by
danzmwl.
Hello @danzmwl,
This can be a valid example with a field named Country :
add_filter('wpmautic_tracking_attributes', function($attributes) {
//We ensure the country exists to avoid sending invalid data to Mautic.
if (isset($_POST['Country']) && !empty($_POST['Country'])) {
$attributes['country'] = filter_var ( $_POST['Country'], FILTER_SANITIZE_STRING);
}
return $attributes;
});
This example will map the field in your form named Country (cf $_POST['Country']) to the field country in Mautic (cf $attributes['country']).
This will work if your form is submitted using the POST method, but it’s the most common usage.
This code must be added in your functions.php theme file or inside the plugin code.
I hope this’ll help 🙂
-
This reply was modified 7 years ago by
shulard. Reason: Add mention about theme / plugin edit