Solved

Is it possible to set a custom "$source" property value via API?

  • 10 November 2021
  • 11 replies
  • 830 views

Badge +3

Hello, 

My company currently integrates with Klaviyo via REST API requests. Specifically, we’re using the /subscribe endpoint to populate Klaviyo lists. The $source property, in newly added profiles, is auto-assigned a value of “API” in our case, and it would be very nice if we could change this to our company name. 

This is the only documentation I can find related to this, but it only mentions manually setting this value. 

https://help.klaviyo.com/hc/en-us/articles/1260804673530-Source-Value-Reference

 

Thanks!

icon

Best answer by alex.hong 12 November 2021, 23:04

View original

11 replies

Userlevel 7
Badge +58

Hey there @nickriley,

Welcome to the Community!
Just to get some clarification, you are looking to change the $source value or rename the source value to be your company name? Is this due to how you track users coming into your site or performing some action?

 

Best,

Alex

Badge +3

Hey @alex.hong , 

Thanks for the welcome!

To clarify, I suppose it’s not just have it be set to our company name. For our use case, we maintain several apps that add profiles to a specific list. Because these apps are just using the Klaviyo REST API, all the profiles get their $source value set to “API”. It would be really nice if we could differentiate between these. The source can be manually set to a custom string in the UI, but I’m having trouble finding any documentation for setting it via API. 

Regards,

Nick

Userlevel 7
Badge +58

Hey @nickriley!

Thanks for the clarification. You can achieve this by including $source in the payload using the subscribe endpoint for any net-new users to rename. So $source = name of company as seen below.

Let me know if that helped!
Alex

Badge +3

@alex.hong, that worked! Thanks for that. 

Userlevel 7
Badge +58

Glad it worked @nickriley! Thanks for the collaborative effort and hope you have a good rest of your day!

 

All the best,

Alex

Badge +1

Hi,

 

How could I update the $source property when unsubscribing users via API?

 

I’ve tried to pass this as part of the unsubscribe payload:

{
api_key: XXXX,
emails: [ 'email@email.com'],
$source: 'Subscription Form'
}

 

The above doesn’t do anything for me. 

 

Regards,

Nico

Userlevel 7
Badge +58

Hi there @NicoSpoke,

I believe per our documentation for unsubscribing via API, I don’t see a method to unsubscribe AND update a profile property within the same step. This is probably due to the include $source action not being a delete request like the unsubscribe method.

 

Best,

Alex

Badge +1

Hi @alex.hong 

 

We want to use the List Growth report where we can easily see how users subscribed or unsubscribed from our website. At the moment we can update the $source property value when subscribing users, and in the List Growth report we can see the different $source values. However, we would also like to see the $source property being updated when unsubscribing so in the report we can evaluate the location on the site where users unsubscribe from. At the moment we just get API as the value when unsubscribing.

 

Thanks,

Nico

Userlevel 7
Badge +58

Hi there @NicoSpoke,

It's not possible to update a property value when making the DELETE request to the /subscribe endpoint. $source can be sent on any request as a profile property but it’ll only show up on the list growth report if it comes in on the same subscribe request as the one that initially landed that person on the list. Changing it afterwards won’t change the report. A profile’s $source will be set to API if they were added through Klaviyo’s API, or set to Manually Initiated if they were added using Quick Add. If you had different API keys then you could filter for something like $source = -(number).

The "API" source refers to profiles that were added to your account using one of our APIs linked here as opposed to through a Klaviyo form or from one of our first-party integrations (MailChimp, Facebook, etc).

This typically refers to either a custom integration that you or your team might've built, or it can refer to a third-party integration that you might be using through another service.

If it's a custom integration, you can include the $source property when sending over data so that our system updates the property to something more specific than a general API source. I see that your account does indeed use a custom eCommerce integration so this is likely what the source is referring to.

If it's a third-party integration (such as a third-party signup form integration), this shouldn't be too much of an issue if you are only using 1 third-party service to collect profiles since you could attribute all profiles with source "API" to that service.

Adding extra custom properties to identify where someone subscribes from might be an alternative way. You might have already looked at our article, however, I am going to provide it here in case you need it: How to Add Custom Fields to a Legacy Form.

An alternative method to achieve specific segmentation if you are using a URL would either involve passing the page URL as a hidden property from your form so it is added a custom property to each signed up profile (on the basis the plugin supports this) or you will need to pass this property via an API call which you may need to work with a developer to setup. 

 

All the best,

Alex

 

Badge +1

Hi, 

We have a custom integration and we subscribe all our customers via the Klaviyo API `subscribe` endpoint. In our test klaviyo account, we started to pass the $source property as part of the payload and in the list report we can see the location in our website where this customer subscribed from. It’s very useful for the growth team as they can evaluate where customers “subscribe” from easily. This process works, and its great. 

 

However, since all our unsubscribes also use our custom integration via API, it’s a bit redundant to see the list report growth showing API as the only route of unsubscribing. Ideally we would be able to list the different parts of our site where customers unsubscribe from too. It’s seems from the documentation that with the DELETE endpoint (unsubscribe) we cannot pass the $source property. Would making an identify call with the $source property work? Or will it just update the profile data but the list report would still show as API?

 

Thanks,

Nico

Userlevel 7
Badge +58

Hi @NicoSpoke,

So for this case, there really is no other thing to mention as I’ve covered all bases regarding the expected behavior and mechanics of the $source property and API. The list growth report will still just show API no matter what; Certain 3rd party integrations will show unsubscribe but not if you’re just using our API. Unfortunately, there is not much more to go over.

 

All the best,

Alex

Reply