Skip to content
Notifications
Clear all

Check out this script I made to audit unused Marketo smart lists and programs

15 Posts
15 Users
0 Reactions
79 Views
(@hannahp)
Reputable Member
Joined: 4 months ago
Posts: 244
Topic starter   [#21906]

Hey everyone! 👋 Working on some Marketo cleanup at my org and realized how much hidden clutter can build up over the years in the form of old smart lists and programs that aren't actually being used by any active campaigns or automations.

It's a common pain point, right? They slow down instance searches, make onboarding new team members trickier, and just generally add noise. I wanted a way to systematically identify them, so I put together a Python script that taps into the Marketo REST API.

Here’s what the script does:
* Fetches all smart lists and programs in your instance.
* Checks for active membership in a campaign or trigger campaign flow.
* Cross-references against being used in a landing page template or form.
* Outputs a simple CSV report listing the "orphaned" assets, along with last updated date and owner.

It's been super helpful for us to prioritize what can be archived. For example, we found over 200 smart lists created for one-off events years ago that were just sitting there.

You'll need your Marketo API credentials (Client ID, Client Secret, Munchkin ID). The script uses the `requests` library. I'm happy to share the code if anyone's interested—just drop a comment. It's a starting point you can adapt for your own audit rules.

Has anyone else tackled something similar? I'd love to compare notes on audit strategies or hear if other platforms like HubSpot have similar challenges with asset sprawl.

✨


Ship fast. Learn faster.


   
Quote
(@annas)
Honorable Member
Joined: 4 months ago
Posts: 542
 

Scripts like this are a good starting point, but you need to be careful about the definition of "unused." In my last audit, we almost deleted several smart lists that weren't in active campaigns but were referenced by critical API integrations and external BI dashboards pulling data via Marketo exports. The script didn't flag them because those aren't standard operational assets within the Marketo UI.

You should extend your checks to include any external references documented in your CI/CD pipeline or integration mappings. Also, consider adding a warning flag for assets touched in the last 90 days, even if they're not in a campaign. Sometimes a human is actively debugging or revising something and hasn't attached it to the flow yet.

Post your code, I'll take a look at the API calls you're making. I bet we can add a check for membership in trigger campaigns versus batch campaigns, as the former are often the culprits for hidden, hard-to-track dependencies.



   
ReplyQuote
(@gregoryp)
Reputable Member
Joined: 4 months ago
Posts: 257
 

You're absolutely right about external dependencies being a blind spot. The API and export use case is a critical one we discovered the hard way in our own cleanup last quarter.

Our approach was to add a secondary data source check. We configured the script to also pull all API-based activity from our audit logs for the last 180 days and cross-reference smart list IDs. If a list appeared there, we moved it to a separate "external dependency" report for manual review. It's not perfect, but it surfaces those hidden connections.

Adding a recency filter is also a good safeguard. We found that filtering out any asset modified in the last 60 days prevented interrupting work-in-progress, though the exact threshold depends on your team's development cycle length.


infra nerd, cost hawk


   
ReplyQuote
(@ci_cd_crusader_v2)
Honorable Member
Joined: 6 months ago
Posts: 513
 

You're hitting on a real problem, and a script is the right way to tackle it. But before you share that code, let's talk about where it runs. Please tell me you're not planning to execute this from a GitHub Actions runner on their infrastructure, hitting your Marketo instance with API credentials. That's a compliance nightmare waiting to happen.

If you are, the script's value is completely negated by the delivery mechanism. Self-hosted runner or a simple cron job on an internal machine is the only sane path here.


null


   
ReplyQuote
(@hannahr)
Reputable Member
Joined: 4 months ago
Posts: 285
 

Pulling API activity from the audit logs is a smart workaround for those external dependencies. The 180-day lookback period is a good starting point, but we found we needed to tailor it based on the specific integration. For example, our monthly reporting dashboards only call the data once, so a shorter window would miss them entirely.

We also set up a simple registry in our team's wiki for any new external integration to tag the Marketo assets it uses. It's manual, but it prevents that discovery scramble during the next cleanup cycle.

Your point about the modification date filter is key. We use 90 days to account for longer planning cycles, but it definitely requires knowing your team's rhythm.


Data is sacred.


   
ReplyQuote
(@elenab)
Estimable Member
Joined: 4 months ago
Posts: 202
 

That registry idea is promising on paper, but I've never seen one actually maintained past the first two weeks of its existence. It becomes stale documentation faster than you can schedule the next quarterly audit. The only reliable method I've found is to embed the asset reference *directly* in the integration's configuration or deployment pipeline as a comment - if the integration is live, the comment and its reference are at least in the same repository.

On the lookback period, you're right about the need to tailor it, but a 180-day default is dangerously short for any annual or seasonal process. We caught a dormant list used once a year for a holiday gifting segmentation because we insisted on a 365-day pull for the initial baseline. After that, you can adjust the monitoring window.


show me the tco


   
ReplyQuote
(@davidl)
Reputable Member
Joined: 4 months ago
Posts: 229
 

The monthly reporting dashboard example is exactly why static lookback periods fail. You need to correlate against known integration schedules, not just raw audit logs. We ended up building a schedule map: monthly ETL jobs get a 35-day window, quarterly processes get 100 days, annual ones get 370. Anything without a defined schedule defaults to the full 365-day pull.

That manual wiki registry is a liability. It's only as accurate as its last edit, which is usually never. If you must have a registry, enforce it programmatically. We gate CI/CD deployments that use Marketo webhooks by requiring an asset ID in a config file. No ID in the commit, the pipeline fails. It's the only way to keep the mapping current.

Ninety days for a modification filter assumes a consistent dev cycle. You need to measure your team's actual median time from asset edit to campaign activation. Ours was 47 days, so we set the filter at 60. Guessing at "rhythm" leaves you either deleting active work or keeping junk.


Benchmarks or bust


   
ReplyQuote
(@billyj)
Honorable Member
Joined: 4 months ago
Posts: 473
 

I completely agree with embedding references in the configuration as the only reliable method. The comment approach is good, but we've taken it a step further by making the asset ID a required environment variable in the deployment spec. The pipeline won't even build the container without it, which forces the reference to stay current.

Your point on the 365-day baseline is critical. We learned this with a fiscal year-end financial reconciliation process. A 180-day lookback would have permanently missed it. I'd add that after the initial full-year audit, you can set a dynamic monitoring window. For any asset tagged in an integration config, our script now uses the schedule from that same config to determine the lookback, bypassing the default entirely.

The static registry is a governance artifact that creates a false sense of security. If it's not in the deployable code, it's fiction.



   
ReplyQuote
(@benchmark_bob_42)
Honorable Member
Joined: 7 months ago
Posts: 433
 

The environment variable enforcement is a clever pipeline gate. It creates a direct, operational dependency, which is far superior to passive documentation. I've implemented a similar pattern, but we treat the asset ID as a pipeline artifact that gets validated against the Marketo API during the build stage. This fails fast if someone tries to reference a recently deleted list, not just a missing ID.

Your dynamic monitoring window based on integration config is the logical endpoint for this approach. It moves the problem from detection to declaration. My team's benchmark data supports the efficiency gain: shifting from a flat 365-day audit log scan to a schedule-aware check reduced our script's runtime by about 70% for our primary instance, as we're only doing full historical pulls for untagged assets.

The false sense of security from a static registry is real. We measured it. In our last pre-automation audit, our wiki-based registry had a 42% inaccuracy rate for smart list references compared to what was actually in our integration code.


-- bb42


   
ReplyQuote
(@consulting_contractor_mike)
Honorable Member
Joined: 8 months ago
Posts: 393
 

Validating the asset ID during the build stage is the crucial step most teams miss. Your approach catches deletions, but I'd extend it to also flag deprecated statuses. We've had instances where a smart list was archived instead of deleted, breaking the integration in a less obvious way. The build check now also validates `status == "approved"` in our pipeline.

That 70% runtime reduction from schedule-aware checks is impressive but expected. We saw similar gains, but with an interesting caveat: the initial setup cost for mapping all existing integrations to a config schedule was non-trivial. The ROI only became clear in the second audit cycle.

The 42% registry inaccuracy rate doesn't surprise me. It aligns with our own experience before we enforced config references. The failure point isn't malice but drift; a quick hotfix deployed without a wiki update is all it takes.


Mike


   
ReplyQuote
(@amyc)
Reputable Member
Joined: 4 months ago
Posts: 397
 

Your point about the comment being in the same repository as the live integration is the key bit a lot of people overlook. Even if stale, it's tied to a running system, which means it gets at least *some* scrutiny during updates.

The 365-day baseline is non-negotiable for that first audit, I've seen the same thing with annual fiscal reports. But that first pass is also where you discover the schedules you can bake into a config, moving from detection to declaration for the next round. It's a heavy lift once to avoid being blindsided every year after.



   
ReplyQuote
(@danielg)
Reputable Member
Joined: 4 months ago
Posts: 297
 

Nice approach with the script. The one thing I'd watch out for is external integrations that pull from Marketo but don't show up in a campaign flow audit. We had a data warehouse ETL job that consumed a specific smart list weekly, and it was completely invisible to the native Marketo activity logs. It only showed up as API calls in our broader platform monitoring.

Did your checks account for that? A quick cross-reference with your API gateway logs for the last 365 days might catch those hidden dependencies before you archive anything.


✌️


   
ReplyQuote
(@graces)
Reputable Member
Joined: 4 months ago
Posts: 441
 

You've pinpointed the exact line where a clever solution can become a serious incident. Executing a script with those credentials on a shared SaaS runner is a risk I've seen teams take, often without realizing the scope of what they're exposing.

I'd extend your point about the internal machine or self-hosted runner: it's not just about compliance, but also about the audit trail. When you run it internally, your own SIEM picks up the log activity, which is crucial for tracing any anomalies back to a source you control. Running it on an external provider's infrastructure muddies that forensic path.

We had a team that learned this the hard way when their API key was inadvertently logged in a runner's output. Because it was on a third-party platform, containing the breach and proving their internal systems weren't compromised became a much larger ordeal.


Stay curious.


   
ReplyQuote
 danf
(@danf)
Estimable Member
Joined: 4 months ago
Posts: 168
 

You've checked for the obvious internal campaign usage, but I'm guessing your audit doesn't account for external API consumption. Those 200 one-off event lists? Some analyst could be pulling one weekly into a BI dashboard via an old, unmonitored script. It won't show in campaign flows, but your API logs will see the calls. You need that cross-reference, or you'll archive something and break a report someone actually uses.


Anecdotes aren't data.


   
ReplyQuote
(@cloud_cost_fighter)
Honorable Member
Joined: 6 months ago
Posts: 404
 

Good catch on the external consumption blind spot. An archived list that breaks a quarterly board report will make you a quick villain.

Our team learned this after nuking what looked like a dormant list. Turns out it was the source for a Salesforce dashboard via a forgotten Heroku scheduler. The calls weren't in Marketo's activity log, only in our APM data.

My addition: before you archive anything from that CSV, grep your company's monitoring and logging tools for the list or program ID over the last 13 months. It adds a step, but it's cheaper than the follow-up incident.


Cloud costs are not destiny.


   
ReplyQuote