Create a segment where a custom date field is older than 90 days

RyanE6
Campaign Contributor

Hi there,

 

I am working on an integration and would like to auto-create some segments for our users. Some segments will be based on dates within custom fields.

 

For example:

- Customers who have made a purchase in the past 30/60/90 days.

- Customers who have made a purchase more than 30/60/90 days ago.

 

The first one seems possible using something like this:

 

"name": "Made a purchase in last 90 days",
"segment_criteria": [
    "version": "1.0.0",
    "criteria": [
        "type": "and",
        "group": [
            [
                "source": "contact",
                "custom_field": "wylie_last_purchase",
                "op": "contains-any",
                "const_date_value": "last-n-days",
                "date_param": "90",
            ]
        ]
    ]
]​

 

However I am not sure how to do the second one. Is there an operator that does the opposite of "contains-any" for dates?
 
3 REPLIES 3
Courtney_E
Moderator

Hello RyanE6,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

Segments that are built via the API must follow the same criteria as segments that are built within the website UI, so for Custom Contact fields you can only use "is", "is not", "contains", "starts with", or "is blank", and there are no options available for sorting them by date. 

 

I have tracked the open feature request "Segments - Option to Segment Custom Field by Date"  with your account. This request is currently under review for future consideration by our engineering team. Your feedback and experience with this request is essential to improving our product, so thank you for reaching out to us regarding this matter.

 

The only contact values that you can use to create a segment by date are "Date Added", which is the date that the contact was created, and "Last Date Edited" which should be the date that the contact details were last edited. 

 

Using the API, there are a few different ways that you could accomplish what you are looking to do, but it would require some additional programming within your application in order to update the date specifications in the way that you are wanting.

 

Here is one example of a flow that would accomplish this via the API:

 

[Step 1]

Get the "custom_field_id" for the field you want to work with:

 

GET custom_fields Collection

https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts_Custom_Fields/getCustom... 

 

[Step 2]

Get the "list_id" for the list where those contacts are stored: 

 

GET Lists Collection

https://v3.developer.constantcontact.com/api_reference/index.html#!/Contact_Lists/getLists

 

[Step 3]

Make a call to GET /contacts and specify the List ID under the "lists" parameter, and for the "include" parameter, set the value to "custom_fields", like so:

 

Example: 

api.cc.email/v3/contacts?lists=04fe9a97-a579-43c5-bb1a-58ed29bf0a6a&include=custom_fields

 

GET Contacts Collection

https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts/getContacts

 

From the response body data, for each contact where the "custom_field_id" matches the value of the "custom_field_id" we retrieved in Step 1, you'll want to save save the following fields for each contact in an array: "contact_id" & "value" (for that specific custom field, as there may be more than one)

 

[Step 4]

You'll then want your program to to parse the array data to return only contact data with a "value" within the desired date range, then you can add those contacts to a list, or add a tag to them for use in a segment.

 

Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
RyanE6
Campaign Contributor

Thanks for the helpful reply. I'm surprised that segments do not support custom date fields.

 

The problem I think I will have with your suggestion is that the data in Constant Contact will become stale unless we program our application to perform daily tasks to update contact/tagging information.

 

For example, if I were to modify our software to tag contacts who have made a purchase within the past 30 days, I would have to create some kind of task to run each day in order to remove the tag once their last purchase date increases past 30. That would be a major effort for us and I imagine any other developers who wish to add similar functionality to their software as well. I think it would be much simpler and more efficient to update a single contact's custom field with a date at the time of a purchase, and then later segment based on that. 

 

At an higher level, I feel like I a missing some details about how to integrate as richly as others seem to be. If we were to want out software to support features like sending offers to users with abandoned carts, where would we start with that? Is that simply by tagging or is there something more appropriate that I am missing?

 

Ryan

Courtney_E
Moderator
0 Votes

Hello RyanE6,

 

Thank you for reaching out to Constant Contact API Developer Support. 

 

I completely understand, and can certainly see the value in having dates in custom fields available for segmentation purposes. Also, because the feature request was already open, this means that other customers have made this request as well. The priority of feature requests is typically broken down into a number of factors, one of which being the amount of customer interest that is tracked for that request. I have set your account to be notified if we either implement such a feature, or reach a decision that it will not be implemented.

 

Regarding abandoned cart emails, Constant Contact has built integrations with Shopify & WooCommerce, however these integrations do not use our public API, and use a different internal system to process and send those emails.

 

[Article] Use pre-built templates to send a standard abandoned cart reminder series to your Shopify or WooCommerce customers

https://knowledgebase.constantcontact.com/articles/KnowledgeBase/44330-Automated-marketing-journey-f...

 

Our system isn’t really configured to send individual emails like that, as Constant Contact is built primarily for sending bulk emails to lists of contacts, and sending a large amount of emails to lists that only contain one contact could potentially make viewing campaign reporting and statistics cumbersome.

 

However, there are certain ways that you could work around this by using the V3 API in combination with an HTML Custom Code email template sent to a specific list on a schedule using custom contact fields. 

 

Before developing your own application for integration with Constant Contact’s API, you’ll need to verify that you are able to set up your application to pull contact and cart data via your e-commerce platform’s API documentation. Once you have that configured, you can begin programming your application to sort out which variables you need and parse them into the correct format for Constant Contact’s API.

 

If you would like more detailed steps regarding this process, feel free to contact our team directly at webservices@constantcontact.com

 

Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up