Monetize AI Agent traffic with server-side ads for Drupal 9/10/11.
AI Agents (ChatGPT, Claude, Perplexity, Google AIO) don't execute JavaScript - traditional ads are invisible to them. Smalk injects ads server-side so they appear in the HTML before it reaches AI Agents.
- Drupal 9.x, 10.x, or 11.x
- PHP 8.0+
- Smalk account (app.smalk.ai)
- Download the
smalkfolder - Place it in
modules/contrib/smalk(ormodules/custom/smalk) - Go to Extend (
/admin/modules) - Search for "Smalk" and check the box
- Click Install
- Go to Configuration → Web services → Smalk (
/admin/config/services/smalk) - Enter your API Key from Smalk Dashboard → Settings → API Keys
- Click Save configuration
Your workspace information will be fetched automatically.
Add this HTML where you want ads to appear:
<div smalk-ads></div>- Edit your page or article
- Click the Source button in the editor toolbar
- Paste
<div smalk-ads></div>where you want the ad - Save your content
Use unique IDs to distinguish different ad slots:
<div smalk-ads id="article-top"></div>
<div smalk-ads id="article-bottom"></div>{{ '<div smalk-ads></div>'|raw }}- Go to Structure → Block layout → Custom block library
- Create a block with Full HTML format
- Add:
<div smalk-ads id="sidebar-ad"></div> - Place it in your desired region
The module automatically:
- Tracks every page visit - Including AI Agent traffic (server-side, before cache)
- Injects ads into your content - Replaces
<div smalk-ads>with actual ad HTML - Ensures fresh ads - Pages with ads are not cached to enable proper ad rotation and impression tracking
- Check Publisher Status is "Active" in module settings
- Verify "Enable AI Search Ads" is checked
- Ensure you have active ad campaigns in your Smalk Dashboard
This is configured automatically on install. If you still have issues:
- Go to Configuration → Web services → Smalk
- Open Advanced Settings → Troubleshooting
- Click Re-configure Text Formats
- Go to Reports → Recent log messages (
/admin/reports/dblog) - Filter by type "smalk"
- Dashboard: app.smalk.ai
- Documentation: smalk.ai/docs
- Support: support@smalk.ai
GPL-2.0-or-later