Count the number of Marketo form fills in the last hour (across all leads) using FlowBoost

FlowBoost’s FBCounter module, most often used to count and cap event registrations, really just counts things.

Those things could be unique web pages visited by a lead... leads that share the same email domain... or form fills over a recent time range, as we’ll do today.

The “time range” part is made possible by setting a TTL (Time-To-Live) value on individual FBCounter entries. That’s how long until an entry gets deleted automatically — and the count decrements in turn.

So if you set the TTL to 3600 seconds (1 hour), the current count is always the total in the last hour. Make sense?

Create a simple FlowBoost webhook to update the counter, name it Update Form Fill Counter:

FBCounter.create("/formFills/byHour/", true, { ttl : 3600 })
.then( success );

And create another webhook to fetch the current count, name it Get Form Fill Counter:

.catch( () => 0 )
.then( success ); 

That second webhook returns a simple JSON payload with the count:

  "response" : 99

Map the property response to an Integer field and do whatever you want with it!

For both ’hooks, make sure you’re using the Pro mode URL:$current/run?authoringEnv=pro

The intent of having 2 webhooks is that

  • you trigger the 1st one on every Filled Out Form
  • you periodically run a resource lead — that’s a lead dedicated to running such global tasks — through the 2nd one, using Send Alert to celebrate successful campaigns or fret about lower-than-expected responses

If you wish to have a single webhook that both updates and returns the current count, you can do that too:

FBCounter.create("/formFills/byHour", true, { ttl : 3600 })
.then( () => FBCounter.count("/formFills/byHour/") )
.then( success );