Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Property value as array #75

Open
wardwj opened this issue Nov 4, 2021 · 3 comments
Open

Property value as array #75

wardwj opened this issue Nov 4, 2021 · 3 comments

Comments

@wardwj
Copy link

wardwj commented Nov 4, 2021

Passing an array (defined as a string) as a property value and encountering this issue:

Output in klaviyo:
testing = [\"jon\",\"doe\"]

This is the code I'm using to create this
$this->klaviyo->updateProfile($klaviyoProfile["id"], ['testing' => '["jon","doe"]' ])

@wardwj
Copy link
Author

wardwj commented Nov 4, 2021

As per the documentation this is how the format is documented to save array values on a property:

https://help.klaviyo.com/hc/en-us/articles/115005237648-About-Data-Types#list6

@smoucka
Copy link
Contributor

smoucka commented Nov 5, 2021

Hi @wardwj

Thanks for bringing this to our attention.

I think there are two issues at hand here. First it appears the array in your example is actually a string which is why you see the escaped quotes on the profile in Klaviyo. Unfortunately, if you pass that array in as an array rather than a string Klaviyo will save each value in the array with an index suffix e.g. test[0], test[1]. The issue occurs when converting the query parameters to a query string. Php's http_build_query automatically indexes the keys e.g. ?test[0]=jon&test[1]=doe and Klaviyo expects those values to instead be formatted like ?test=jon&test=doe.

While this can be resolved in future versions of the SDK, in the meantime you can hopefully utilize the identify endpoint. One thing to note, you'll need to use the email address instead of the profile ID. Here's an example:

$toUpdate = new KlaviyoProfile(
    array(
        '$email' => '[email protected]',
        'a_list_prop' => ['hey', 'hi', 'howdy']
    )
);
$client->publicAPI->identify($toUpdate, true);

@1stevengrant
Copy link

any ETA of when this is likely to resolve?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants