Please note that we provide the code snippets and content on this page are 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.

Example

  • A user visits: https://yoursite.com?ref=1.
  • They click on the ad with the target URL: https://partnersite.com. (due to link cloaking, the link in the browser will show as something like https://yoursite.com/linkout/123
  • User lands on https://partnersite.com?ref=1
  • 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;
}