Skip to content
Home » Documentation » Contact Form 7 – Dynamic Text Extension » Shortcodes » DTX Shortcode: Referrer URL

DTX Shortcode: Referrer URL

This shortcode included in Contact Form 7 – Dynamic Text Extension returns the referring URL if it exists. Please note that this is not necessarily reliable as not all browsers send this data. There are no additional attributes other than obfuscating.

[CF7_referrer]

Example

The dynamic text form tag for retrieving the referring URL would look like this:

[dynamictext inputname "CF7_referrer"]

Cache Compatibility

If the HTML of your webpage is being cached, preventing the server from processing the shortcode before displaying the form, then you can enable cache compatibility mode for this form tag.

However, this built-in shortcode is unique in that it does not make an AJAX request. Instead, it simply uses JavaScript to pull the referring URL (only if the browser has set it).

Demo

Check it out! Below are two fields, both using the same CF7_referrer shortcode, but the second one has cache compatibility enabled so it’s pulled via JavaScript instead of a server variable.

    View Source Code

    View the current source code for the server-side shortcode or for the client-side JavaScript function.

    Related Post Module Attributes Before

    array(29) {
      ["post_type"]=>
      string(4) "post"
      ["post_id"]=>
      string(1) "0"
      ["exclude"]=>
      string(1) "0"
      ["title"]=>
      string(32) "Related Articles & Tutorials"
      ["description"]=>
      string(0) ""
      ["max"]=>
      string(1) "3"
      ["post_ids"]=>
      string(0) ""
      ["exclude_ids"]=>
      string(0) ""
      ["is_series"]=>
      string(0) ""
      ["featured_term"]=>
      string(3) "307"
      ["exclude_terms"]=>
      string(0) ""
      ["exclusive"]=>
      string(1) "1"
      ["order"]=>
      string(4) "DESC"
      ["show_image"]=>
      string(2) "on"
      ["image_size"]=>
      string(6) "medium"
      ["menu_order_label"]=>
      string(0) ""
      ["show_order_label"]=>
      string(2) "on"
      ["show_date"]=>
      string(2) "on"
      ["show_meta_keys"]=>
      string(2) "on"
      ["show_modified"]=>
      string(0) ""
      ["show_author"]=>
      string(0) ""
      ["show_categories"]=>
      string(0) ""
      ["show_primary_category"]=>
      string(0) ""
      ["show_description"]=>
      string(0) ""
      ["show_reading_time"]=>
      string(2) "on"
      ["show_cta"]=>
      string(2) "on"
      ["cta"]=>
      string(9) "Read more"
      ["autoplay"]=>
      string(0) ""
      ["allow_sticky"]=>
      string(0) ""
    }
    

    Related Post Module Attributes

    array(29) {
      ["post_type"]=>
      string(4) "post"
      ["post_id"]=>
      string(1) "0"
      ["exclude"]=>
      string(1) "0"
      ["title"]=>
      string(32) "Related Articles & Tutorials"
      ["description"]=>
      string(0) ""
      ["max"]=>
      string(1) "3"
      ["post_ids"]=>
      string(0) ""
      ["exclude_ids"]=>
      string(0) ""
      ["is_series"]=>
      string(0) ""
      ["featured_term"]=>
      string(3) "307"
      ["exclude_terms"]=>
      string(0) ""
      ["exclusive"]=>
      string(1) "1"
      ["order"]=>
      string(4) "DESC"
      ["show_image"]=>
      string(2) "on"
      ["image_size"]=>
      string(6) "medium"
      ["menu_order_label"]=>
      string(0) ""
      ["show_order_label"]=>
      string(2) "on"
      ["show_date"]=>
      string(2) "on"
      ["show_meta_keys"]=>
      string(2) "on"
      ["show_modified"]=>
      string(0) ""
      ["show_author"]=>
      string(0) ""
      ["show_categories"]=>
      string(0) ""
      ["show_primary_category"]=>
      string(0) ""
      ["show_description"]=>
      string(0) ""
      ["show_reading_time"]=>
      string(2) "on"
      ["show_cta"]=>
      string(2) "on"
      ["cta"]=>
      string(9) "Read more"
      ["autoplay"]=>
      string(0) ""
      ["allow_sticky"]=>
      string(0) ""
    }
    

    2 thoughts on “DTX Shortcode: Referrer URL”

    1. Unfortunately, the title of a referring page is not stored in the browser. Sometimes the URL isn’t either. The best you could do is create a custom shortcode that can look up a page’s title from it’s URL, similar to how social media engines scrape meta data when provided a URL to share.