HubSpot stores heaps of data about your contacts, but it doesn’t natively track when they entered your CRM. By stamping every record with the day it was created (or updated) you unlock powerful, timing-based automation. The tiny custom coded action below handles that stamp in real time.
- Reads the current server date.
- Writes the day name (
Sunday
…Saturday
) into a custom property. - Enables workflows to branch, assign, or nurture by weekday.
Because day-based behavior varies wildly across businesses, we’ll lean hard into practical use cases next.
Why Day-of-Week Matters: High-Impact Use Cases
Industry / Team | Day-Based Automation Ideas |
---|---|
Sales teams | Rotate lead assignments so reps each own a specific weekday, balancing workload and response SLAs. |
Marketing automation | Trigger nurture sequences on the contact’s sign-up weekday to replicate the “best performing” send time automatically. |
E-commerce | Offer limited-time coupons that expire before the next weekend to boost mid-week conversions. |
Event management | Route weekend registrants to a “light-touch” queue while weekday sign-ups get immediate follow-up from staff. |
Customer support | Prioritize Monday-created tickets (often the heaviest volume) and auto-escalate if still open by Wednesday noon. |
Healthcare clinics | Segment patients who inquire on weekends and send self-scheduling links versus weekday callers who can be phoned back directly. |
Field services | Schedule technicians based on weekday request peaks (e.g., lawncare leads on Fridays, HVAC emergencies on Mondays). |
SaaS onboarding | Kick off live walkthroughs only on Tue–Thu sign-ups, while Mon/Fri sign-ups receive recorded demos. |
Nonprofits | Send donation reminders the same weekday the donor first engaged, mirroring their original behavior. |
Step-by-Step Implementation
1. Create the Custom Property
- Settings → Properties → Contact Properties → Create property
- Name it
Day of the Week
. - Field type: Dropdown select with options Sunday–Saturday.
2. Generate a Private App Token
- Settings → Integrations → Private Apps → Create app
- Enable scopes:
•crm.objects.contacts.read
and.write
- Copy the token and store it as a secret (e.g.,
DAY_OF_WEEK_UPDATER
) inside your custom code action.
3. Add the Custom Code Action to Your Workflow
Build a Contact-based workflow that triggers on form submission, list membership, or simply runs daily on new contacts. Insert a Custom Code action and paste the script below, replacing the token reference with your secret.
const axios = require('axios');
// Get today’s day name
const currentDate = new Date();
const daysOfWeek = ["Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"];
const dayOfWeek = daysOfWeek[currentDate.getDay()];
// HubSpot endpoint & token
const HUBSPOT_API = "https://api.hubapi.com/crm/v3/objects/contacts";
const HUBSPOT_API_TOKEN = process.env.DAY_OF_WEEK_UPDATER;
exports.main = async (event) => {
try {
const contactId = event.object.objectId;
await axios.patch(
`${HUBSPOT_API}/${contactId}`,
{ properties: { day_of_the_week: dayOfWeek } }, // update your property name
{ headers: {
Authorization: `Bearer ${HUBSPOT_API_TOKEN}`,
"Content-Type": "application/json"
}
}
);
console.log(`Contact ${contactId} tagged as ${dayOfWeek}.`);
} catch (err) {
console.error("Day-of-week update failed:",
err.response?.data || err.message);
throw new Error("Failed to update contact.");
}
};
4. Branch or Enrich Downstream Logic
- Assign sales reps based on
day_of_the_week
. - Delay nurture emails so each step sends on the same weekday originally tagged.
- Enroll “Friday sign-ups” in a Monday re-engagement campaign to reduce weekend drop-off.
5. Test and Validate
- Create a test contact and enroll it.
- Check its
day_of_the_week
property in HubSpot. - Force a date-change by editing your system clock or using a sandbox portal to ensure all seven weekdays map correctly.
Results & Benefits
- Precision timing — optimize outreach to match your audience’s engagement patterns.
- Balanced workloads — evenly distribute new records among teams by weekday.
- Richer segmentation — combine day-of-week with lifecycle stage, persona, or source for laser-targeted cohorts.
- Lightweight code — fewer than 40 lines deliver enterprise-grade flexibility.
Wrapping Up
Sometimes the simplest data point unlocks outsized wins. Adding a day-of-week stamp costs virtually nothing in compute time but pays dividends in smarter scheduling, better conversions, and happier teams. Drop this custom code action into your Ops Hub toolbox (with edits) and watch your weekday-aware workflows take off.
Need more creative applications for day-based automation?