Skip to content

Commit 5bb13d1

Browse files
authored
Merge pull request #675 from AdguardTeam/agm-2388-kb-urltransform-modifier-example
[AGM-2388] Updated the article in KB about the urltransform modifier example
2 parents a52ff74 + ba55651 commit 5bb13d1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/general/ad-filtering/create-own-filters.md

+26
Original file line numberDiff line numberDiff line change
@@ -2951,6 +2951,32 @@ the request to `https://example.com/firstpath` will be blocked.
29512951
29522952
`$urltransform` rules can also be disabled by `$document` and `$urlblock` exception rules. But basic exception rules without modifiers do not do that. For example, `@@||example.com^` will not disable `$urltransform=/X/Y/` for requests to **example.com**, but `@@||example.com^$urlblock` will.
29532953
2954+
**The rule example for cleaning affiliate links**
2955+
2956+
Many websites use tracking URLs to monitor clicks before redirecting to the actual destination. These URLs contain marketing parameters and analytics tokens that can be removed to improve privacy.
2957+
2958+
Below is an example of how to obtain the clean destination link to bypass tracking websites and go directly to the destination.
2959+
2960+
In our example:
2961+
2962+
1. The initial URL (with click tracking): `https://www.aff.example.com/visit?url=https%3A%2F%2Fwww.somestore.com%2F%26referrer%3Dhttps%3A%2F%2Fwww.aff.example.com%2F%26ref%3Dref-123`
2963+
1. Tracking URL after decoding special characters: `https://www.aff.example.com/visit?url=https://www.somestore.com/`
2964+
1. The website you want to visit: `https://www.somestore.com`
2965+
2966+
To clean the URL, we first need to decode special characters (like `%3A``:`, `%2F``/`, etc.) and extract the real URL from the tracking parameters. We will use the `$urltransform` modifier to do this. The following 4 rules replace URL-encoded symbols with their real characters:
2967+
2968+
`/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com\/visit\?url=/$urltransform=/%3A/:/`
2969+
`/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com\/visit\?url=/$urltransform=/%2F/\//`
2970+
`/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com\/visit\?url=/$urltransform=/%3F/?/`
2971+
`/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com\/visit\?url=/$urltransform=/%3D/=/`
2972+
`/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com\/visit\?url=/$urltransform=/%26/&/`
2973+
2974+
After that, we need to write the rule that will block the tracking website and redirect you directly to the target address (somestore.com):
2975+
2976+
`/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com\/visit\?url=/$urltransform=/^https?:\/\/(?:[a-z0-9-]+\.)*?aff\.example\.com.*url=([^&]*).*/\$1/`
2977+
2978+
Tracking links will now be automatically cleaned up, allowing direct navigation to the destination website without tracking.
2979+
29542980
:::caution Restrictions
29552981
29562982
Rules with the `$urltransform` modifier can only be used [**in trusted filters**](#trusted-filters).

0 commit comments

Comments
 (0)