Inherit query parameter

We provide the code snippets and content on this page without any guarantee or support. In most cases, these pages are created on requests or based on individual solutions sent to us by other users. After it was published, we are only reviewing the code and content when we are made aware of an issue. Please let us know if you find one.

Please only use the codes if you understand them and know how to add custom code to your WordPress site.

Advanced Ads Tracking can attach the visited URL’s query parameters to the target URL of the ad. You need to enable this feature through a filter hook before you can use it.

Since Tracking 2.0, this feature only works with link cloaking enabled.


  • A user visits:
  • They click on the ad with the target URL: (due to link cloaking, the link in the browser will show as something like
  • User lands on
  • As you can see, the part ref=1 was taken from the visited URL and attached to the target URL

If your target URL setting also contains parameters, they merge with the visited site’s query parameters.

You can enable this feature through a filter hook, which allows you to control it per ad.

add_filter( 'advanced-ads-tracking-query-string', 'my_tracking_query_string', 10, 2 );
function my_tracking_query_string( $enabled, $ad_id ){
    // only ad 123 should inherit query strings of the visited URL
    if( 123 === $ad_id ) {
        return true;

    return $enabled;

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.