Personalize a marketing email with website pages visited during the last x days in HubSpot

I am supporting a client that is a non-profit publisher of local news. This client is licensed for HS Marketing Professional and HS Sales Professional. The client has an external website where their news articles are published. This website contains the HS tracking code script and the webpages seen on that website are tracked in HS. For instance:

So obviously HubSpot knows the web pages seen by the Contact.

I am trying to leverage the page view data as a personalization token in marketing emails sent by HS. Specifically, I want to know the rolling count of pages seen over the past 3, 7, and 28 days. An example of the use case for this data would be:

“Over the past 7 days you have visited 14 pages on our website.”

How do I do this?

Hey @WhamboMPS,
Thanks for posting in the Community!
I couldn’t find a clear-cut way to set this up. I did, however, find this Community thread, which leads me to believe that this may be best achieved with some sort of workflow automation.
For more in-depth context, I’d like to tag in a few Community experts to see what insight they may have on the best approach here. @Phil_Vallender, @danmoyle, and @RBRESK - are any of you able to provide a setup?
Shane, Senior Community Moderator

hi @WhamboMPS . HubSpot doesn’t have a native personalisation token for rolling page view counts, but you can get close with a workflow and custom contact properties.

The setup looks like this:

Create three custom number properties on the contact: “Pages visited last 3 days”, “Pages visited last 7 days”, “Pages visited last 28 days”. These become your personalisation tokens.

Then build a workflow that runs on a daily schedule and re-enrolls all contacts. The workflow uses the “Number of page views” filter scoped to a relative date range. The catch is that HubSpot’s native workflow math actions can count enrollments or calculate values based on existing properties but cant directly count page view events within a date window natively.

The most reliable workaround is using a workflow with a “Set property value” action using calculated logic, combined with a list that filters contacts by page views in the last X days. The list gives you the segment, the workflow writes a value to the custom property, and that property becomes the token.

It’s not a perfect live count but it updates daily and gets you close enough for the use case you described.

@Abhishek_Singh could you please share a screenshot of this proposed workflow? There are filter options for the date range and for the number of times a page is viewed, but these are mutually exclusive and cannot be combined. As far as I can tell, what you’re proposing is not possible.

Viele dank, Herr Köhler and

ਤੁਹਾਡਾ ਵੀ ਬਹੁਤ ਧੰਨਵਾਦ, ਸ਼੍ਰੀ ਸਿੰਘ।

I will wait a short while for Abishek’s response before weighing in on this. I appreciate both of your efforts to try and help me!

Welcome to the Community @WhamboMPS. This is an interesting use case for pushing HubSpot beyond its standard build. I think you’re looking at a combination of custom properties and serverless functions, but that’s beyond my skillset. In my opinion, this is a job for a developer or technical strategist. Wish I could give you a clear roadmap to what you’re looking for!

Thank you for commenting, Dan. This is one of several issues in HubSpot that I have found that are surprising me. I can express what I need as a SQL statement and rolling counts like this would seemingly be a common use case. I am kind of nonplussed that this is not something that can easily be achieved…

This aligns with how current HubSpot product behave as well. HubSpot can track page views via the tracking code, and it can support segmentation based on behavioral criteria over rolling time windows such as - page views in the last Xdays. Though it does not currently provide a built-in mechanism to directly aggregate those event-level interactions into a persistent per-contact numeric value that can be used directly as a personalization token like 14 page views in the last 7 dayss.

Because of this limitation, there are generally two practical approaches depending on how precise the requirement needs to be..
1. HubSpot-Native approximation approach - Using workflows, lists, and custom properties to approximate rolling-window behavior and store periodic updates. This can work for reporting or segmentation use cases, but it is not truly real-time and has limitations around event-level aggregation logic.
2. External computation approach - Using an external system which could be data warehouse, middleware, or custom application to aggregate behavioral events and then sync the computed values back into HubSpot via API for use in personalization tokens or reporting.

In most implementations. The right approach depends on whether the requirement is for approximate behavioral segmentation within HubSpot or precise, continuously updated event-based metrics for personalization.