klaviyo / php-klaviyo

PHP wrapper for the Klaviyo API
59 stars 48 forks source link

Adding $consent for SMS #61

Closed zenichanin closed 3 years ago

zenichanin commented 3 years ago

I've tried adding the following to the customer_properties and email seems like it consents correctly in Klaviyo by showing up the green checkmark next to the email, but phone number does not.

The phone number shows up in Klaviyo just fine, but I can't get the consent to turn on.

$event = new KlaviyoEvent(
            array(
                'event' => 'Lead',
                'customer_properties' => array(
                    '$email' => $this->email,
                    '$consent' => ['sms', 'email'],
                    'sms_consent' => true,
                    'email_consent' => true,
                    '$first_name' => $first_name,
                    '$last_name' => $last_name,
                    '$phone_number' => '+1' . $this->phone_number
                ),
                'properties' => array()
            )
        );

I've followed couple of Klaviyo tutorials but no luck.

https://apidocs.klaviyo.com/reference/track-identify#track-identify-overview https://help.klaviyo.com/hc/en-us/articles/360054803711-Guide-to-Collecting-SMS-Consent-via-API

njparadis commented 3 years ago

The only path to collect SMS consent we currently support is via a request to the subscriber endpoint, as detailed in the documentation: https://help.klaviyo.com/hc/en-us/articles/360054803711-Guide-to-Collecting-SMS-Consent-via-API#setup-code-variables3