How to Add Multiple Tags to New/Existing Contacts via Webhook Handler Script?

Your software
My Mautic version is: The latest

My PHP version is: 7.4

My Database type and version is: MySQL, latest

Your problem
My problem is:

I have a php webhook handler script that maps data from a Memberpress webhook to Mautic. I need to know two things.

  1. How do I add more than one tag? Mautic documentation does not explain this. Here’s some sample code:

// Grab Data values
$email = $data[‘data’][‘email’];
$firstname = ($data[‘data’][‘first_name’] == ‘’)?$data[‘data’][‘username’]:$data[‘data’][‘first_name’];
$lastname = $data[‘data’][‘last_name’];
$username = $data[‘data’][‘username’];
$tag = ‘MP Hook’;
$address1 = $data[‘data’][‘address’][‘mepr-address-one’];
$address2 = $data[‘data’][‘address’][‘mepr-address-two’];
$city = $data[‘data’][‘address’][‘mepr-address-city’];
$state = $data[‘data’][‘address’][‘mepr-address-state’];
$zip = $data[‘data’][‘address’][‘mepr-address-zip’];
$country = $data[‘data’][‘address’][‘mepr-address-country’];
$stage = 1;
$practice_squad = $data[‘type’];


// Posting the Data
‘firstname’ => $firstname,
‘lastname’ => $lastname,
‘username’ => $username,
‘email’ => $email,
‘address1’ => $address1,
‘address2’ => $address2,
‘city’ => $city,
‘state’ => $state,
‘zip’ => $zip,
‘country’ => $country,
‘tags’ => $tag,
‘practice_squad’ => $practice_squad,
‘stage’ => $stage

$resp = curl_exec($curl);


1 Like

Did you try to do it via a comma separated list? Like $tag = ‘MP Hook, MD Hook, MB Hook’;