Integration¶
After you save a campaign, open SCRIPT on the dashboard. Credentials are already filled in. Copy the tab that matches your stack. Do not paste snippets on public gists or in tickets with the token visible.
All methods send the visitor’s IP, user agent, language, and current URL. Referrer is sent unless Hide Referral is on.
What the check returns¶
Your snippet already implements this:
- If the response is a URL → send the visitor there (affiliate page).
- If the response is
true→ keep them on the current page. - Otherwise → treat as blocked.
Timeouts are about 10 seconds. If the check fails, most snippets fail open (show the current page) or stop — see each tab’s notes on the SCRIPT page.
PHP¶
Best default for PHP landing pages.
- Copy the PHP tab.
- Paste it at the very top of the landing file, before
<!DOCTYPEor any whitespace. - The script redirects when Cloakerly returns a URL, and stops the page when the visitor is blocked.
Requirements: PHP with the cURL extension.
If you see “headers already sent”, something printed output before the snippet.
PHP cURL (no redirect)¶
Use this when you must not change the browser URL (for example the offer must appear inside your domain).
- Copy PHP cURL (No Redirect).
- Allowed traffic is shown in a full-page iframe; blocked traffic sees a blocked message.
The destination must allow framing. If it sends X-Frame-Options: DENY or a strict Content-Security-Policy, the iframe will be blank.
WordPress¶
Two pieces:
- Download Plugin on the SCRIPT page (ZIP). In WordPress: Plugins → Add New → Upload, activate.
- Copy the WordPress tab and paste it into the Cloakerly block on the page/post that receives traffic (or follow the usage steps shown next to the download button).
The check runs before the page renders. It skips wp-admin, AJAX, cron, and REST requests.
Compatible with WordPress 5.0+ and PHP 7.4+.
JavaScript¶
Client-side check. Place the snippet in the page <head> or at the top of the body so it runs immediately.
Limitations:
- The visitor may see a brief flash of the safe page.
- Ad-in-app browsers may block or delay the request.
- IP detection is less reliable than server-side PHP.
Prefer PHP or WordPress when the host allows it.
React¶
Copy the React component and wrap the routes or pages that should be filtered. The component checks on mount, shows a short loading state, then either redirects, renders children, or sends the user to /blocked.
Call the check as early as possible (root layout), not after the offer UI has already painted.
Angular¶
Copy the Angular service and CanActivate guard. Register the guard on the routes that must be filtered so navigation waits for the decision.
Python¶
The Python tab is a Flask-oriented helper: call it at the start of the view, return a redirect if one is provided, or continue rendering the safe page. Adapt the same request (IP, user agent, URL, optional referrer) for Django, FastAPI, or another framework.
Reverse proxy¶
Use when the public domain should stay yours while content is fetched from another origin.
- Copy Reverse Proxy.
- Set
$ORIGIN_URLto the real landing or offer host. - Point the domain (or a path) at this PHP file via rewrite rules.
Flow: Cloakerly check → if allowed, the script fetches the origin URL and streams HTML back. If Cloakerly returns an affiliate URL, the visitor is redirected there. If blocked, the script returns 403.
Link cloaking¶
On the right of the SCRIPT page, Link Cloaking is a Cloakerly-hosted URL that already includes campaign_id and your token.
Use it when you cannot install a snippet:
- Paste it as the ad’s final / tracking URL.
- Use it as a hop in a tracker.
- Share it where only a URL is allowed.
The visitor hits Cloakerly first; then they are sent to the affiliate URL or the safe outcome according to the campaign.
Optional query parameters you may append:
safe_url— fallback if the check allows without returning a URLreferral_url— override referrercurrent_url— override the detected URL
Keep GCLID, FBCLID, and UTMs on this URL (or let the ad network append them) so filters and forwarding still work.
Switching campaigns¶
Each snippet is bound to one campaign_id. To change offers or filters, edit that campaign — you do not need a new snippet unless you created a new campaign. If you copy a snippet from campaign A onto a page that should use campaign B, replace it with B’s SCRIPT.
Testing¶
On the SCRIPT page, Test Campaign opens a sandbox where you can change user agent, UTMs, and referral without paying for clicks. Then load the real landing URL and confirm Reports → Click Logs.