api-documentation
api-documentation copied to clipboard
Historic contact data used in contactfilter is broken in the UI
So it seems, with what was announced in #13 , the UI seems to be broken in multiple places when the segmentation by /contacthistorydata was deactivated.
How to reproduce
Add a new Contact Filter:
curl -s -X POST --user "$KEY:$SECRET" \
https://api.mailjet.com/v3/REST/contactfilter \
-H "Content-Type: application/json" \
-d '{"Name":"purchase_history_above_50","Description":"Contacts have purchased items where one is valued above 50","Expression":"purchase>50","Status":"used"}'
Add a new Campaign Draft and use the new Contact Filter:
Request
curl -s -X POST --user "$KEY:$SECRET" \
https://api.mailjet.com/v3/REST/campaigndraft \
-H "Content-Type: application/json" \
-d '{"Locale":"en_US","Sender":"NÖKU Backstage","SenderEmail":"[email protected]","Subject":"Hello, Buyers valued above 50!","Title":"50 and above newsletter","ContactsListID":"20070","SegmentationID":"365"}'
Response
{ "Count" : 1, "Data" : [{ "AXFraction" : 0, "AXFractionName" : "", "ContactsListID" : 20070, "CreatedAt" : "2018-08-23T06:36:17Z", "Current" : 0, "DeliveredAt" : "", "EditMode" : "tool2", "ID" : 14842, "IsStarred" : false, "IsTextPartIncluded" : false, "Locale" : "en_US", "ModifiedAt" : "", "Preset" : "", "SegmentationID" : 365, "Sender" : "Random Person", "SenderEmail" : "[email protected]", "SenderName" : "", "Status" : 0, "Subject" : "Hello, Buyers valued above 50!", "Title" : "50 and above newsletter", "Url" : "", "Used" : false }], "Total" : 1 }
Result (in the UI)
Last Step: Review – Filter is attached
https://app.mailjet.com/campaigns/summary2/$ID
Last Step: Review – Warning, that there are no users (while there are)
https://app.mailjet.com/campaigns/summary2/$ID
Edit Segment > Calculate Number of Contacts – Error
Expected Outcome
Honestly, I would expect to either work like it used to, or not be present in the UI at all. I would assume that it be easier to just fix the stability issues, than searching every fail in the UI, updating the docs (which do not tell about you deactivating this feature at all), etc. This feature is bundled that deeply with your product, that deactivating it just causes bugs and misinformation all over the place.
Hey Franz,
I hope this message finds you well. I would like to thank you for the detailed and full report of your finding, as this really helped me through the process of investigation.
As you have correctly stated, the historic contact properties do not work through the front-end. You would not be able to assign a historic contact property to a contact with a given value or view the values of this property for a given contact. This functionality is currently available through our API only.
Taking the above into consideration, once a Segmentation is created using a historic contact property within the Expression would break the calculation and would not let you send the Campaign, as it would be reaching (0)Zero Recipients based on the calculation. As a workaround such Segmentation in use with a historic Contact Property could only be used when creating/ sending a Campaign through our API.
Below you would find all the steps that I have taken, and the way the Expression of the Segmentation should be constructed in order to make this work as you wanted it to be.
Creation of Segmentation through the /contactfilter resource
{
"Description":"Only contacts above 50 purchases",
"Expression":"max(1,purchase) > 50",
"Name":"above 50 purchases"
}
Were "max" is the maximum of historic field “purchase” over the n(1) last days
The above Expression means that only the Contacts that have the "Purchase" historic contact property with a last value higher than 50 will be reached via the Campaign using this Segmentation. Keep in mind that when using historic Contact Properties you should combine them with the dedicated functions like Avg,Min,Max, as also shown here : ( https://dev.mailjet.com/guides/?shell#adding-custom-historic-contact-data )
I do understand that through the API you do not have the option to calculate the contacts that this segmentation would reached when in use with such an historic Contact Property within the Expression of the Segment, but this is something that we are working on fixing. The issue was reproduced and reported to our product team which would be taking care of this issue, and once we do have more information or more clearance, I will be more than happy to let you know Franz.
Best, Krassimir
Hi @kmanchikov , thanks for you explanation!
You would not be able to assign a historic contact property to a contact […] This functionality is currently available through our API only.
This is something I understand. Historic contact data (like the purchase of a product) is something that must be delivered by another partys system via API.
Taking the above into consideration, once a Segmentation is created using a historic contact property within the Expression would break the calculation and would not let you send the Campaign, as it would be reaching (0)Zero Recipients based on the calculation. As a workaround such Segmentation in use with a historic Contact Property could only be used when creating/ sending a Campaign through our API.
This is something where I can not completely follow. I would assume to access the same underlying system when it comes to segmentation (no matter if in the CLI or through a UI). I understand that segmentation based on this kind of meta data might not yet be ready/fully implemented in the UI. Having at least the possibility to add segments through the API would be a step closer to strong marketing tool that I can hand over our users. Else all this segmentation would need to happen in a 3rd party tool, which splits the work for users up on completely different systems for a single step: Segmentation.
Keep in mind that when using historic Contact Properties you should combine them with the dedicated functions like Avg,Min,Max, as also shown here.
The link/on-page anchor sadly leads nowhere. In fact it "redirects" to #manage-contacts. – EDIT I can reach the link when I click the icon on the "Creating Contacts with Contact Data" Headline. It simply does not link there when I reload. This is a bug in the docs.
Question: About the functions: Historic data always has a date. How would one use it to segment based on date? Example: Last purchase less than 30d from now? (Pretty much what your UI offers with date ranges for the default/built-in historic data like clicks and opens.).
EDIT: As I read the following…
This historic metadata will be available for segmentation with dedicated functions like Avg,Min,Max...
…and there are …/ellipsis, which indicate that there is more to explore: What are the other (undocumented) functions?
Hi @kmanchikov As some time passed … do you have any additional info or answers to the questions in here? Thanks!
Hi Franz,
Thank you for the reply back, and the detailed breakdown.
In regards to
Having at least the possibility to add segments through the API would be a step closer to strong marketing tool that I can hand over our users.
This is already available through our API as you can create Historic Contact Properties and you can use then for segmentation as I have already provide you one example above.
{
"Description":"Only contacts above 50 purchases",
"Expression":"max(1,purchase) > 50",
"Name":"above 50 purchases"
}
Were as previously said "max" is the maximum of historic field “purchase” over the n(1) last days
Last but not least, the ellipsis in the doc are there to tell that there are still things to be added when it comes to segmentation based on Historic Contact Properties as this is still something that we are working on.
Best, Krassimir
Hi @kmanchikov thanks for your fast response.
This is already available through our API as you can create Historic Contact Properties and you can use then for segmentation as I have already provide you one example above.
I actually meant "add segmentation through API, which is then available in the UI". Sorry, I should have made this clear as it can be understood in two ways.
Were as previously said "max" is the maximum of historic field “purchase” over the n(1) last days.
Do I understand this correct that we can only filter on integer historical values? And only on the min/max or average value?
Are there any hidden gems that allow us to filter for e.g. for customers who made their last purchase X days ago or have a value of "visited location Y" true|false?
Best, Franz Josef
Hi Franz,
Oh, I see. Apologize for misunderstanding. This is currently something that we are working on, but to be honest it's a bit left back in the road map but definitely not forgotten.
Do I understand this correct that we can only filter on integer historical values? And only on the min/max or average value?
That is indeed correct.
Are there any hidden gems that allow us to filter for e.g. for customers who made their last purchase X days ago or have a value of "visited location Y" true|false?
In regards to this one, I am currently experimenting with all different combinations of Expressions so to see how each one of them works and I can tell 100% that for the example that we have first spoken about will work, but for the rest of them I would have to test those out as you could also do having as a guideline the above working Expression.
Best, Krassimir
Hi Krassimir,
no worries! And thanks for the insights on your roadmap. It's definitely appreciated that this might come to the UI at some point! 🚀
Currently I am thinking through how to work around different requirements, regarding historic and static contact (meta) data, with the current possibilities.
About boolean values: In fact, this is something that was quite simple to get around (and maybe something you might want to add to the documentation). If I substitute false with 0 and true with 1, I can easily filter using the max() and min() API filter functions on such a list of historic events. Every contact with a historic event data that needs to be a bool with true|false, would be filterable with an Expression of…
"max( 0, bool_historic_event_values ) > 0equalstrue-"min( 1, bool_historic_event_values ) < 1equalsfalse
This only forces us to transport boolean values as their integer counterparts to your system.
About dates and date-ranges: ~~I am still left in the dark on how to approach this one. You can read in #18 that I already have difficulties keeping the stack clean via the API. I will post an update, once I was able to get further into this.~~ We will probably store UNIX timestamps here, which make comparisons <>= easier.
About historic events and marketing automation: Do you have any idea how to trigger rules like "Visited site X at least N days ago and purchased Y tickets." with the current set of possibilities?
Sidenote: The most limiting part at the moment seems to be, that a historic entry can only hold a single data-point. This seems to force us to add multiple single entries on a single event (for example purchase value, purchase category, purchase amount, …). Any hint on how we could optimize this approach would be appreciated. The main pain point is, that this would also force us to build multiple filters (for different, but highly connected/ coupled historic event data entries) that we need to combine in a single contactfilter call.