The {get} merge tag
Note: The {get} merge tag comes with GravityView. If it isn’t replaced in GravityExport, GravityCalendar, or another add-on, check that GravityView is installed and active.
The {get} merge tag captures or shows information from a URL parameter.
Example URL:
https://gravityview.demo.gravitykit.com/view/tasks/?first=name

The {get} merge tag can be used inside Custom Content fields and wherever other merge tags are used in GravityView:

{get} also works as a comparison value in Advanced Filtering conditions:

Basic use:
{get:url-parameter}
For a worked example, see how to show a person’s name with {get} and [gvlogic].
The {get} merge tag format is {get:param}, where param is the name of the URL parameter whose value you want to show. In {get:first-name}, the URL parameter is first-name.
To show a person's first name in a Custom Content field using {get:first-name}, you could use the following URL:
example.com/view/my-view/?first-name=Floaty
With that URL, the content My name is {get:first-name} shows "My name is Floaty."
If the URL doesn’t include the parameter, {get} is replaced with nothing. In an Advanced Filter, a condition such as “is {get:deal}” then shows only entries where the field is empty, while “contains” and “is not” show every entry where the field has a value.
In a [gravityview] shortcode, an empty {get} in search_value lists every entry unless you add search_value_empty="none". The GravityView block and the page builder widgets have the same choice: set When Search Value is empty to Show no entries. A new block starts there once you choose its View.
Using {get} with the [gvlogic] shortcode #
Use {get} inside [gvlogic] to show content only when the URL holds a given value:
[gvlogic if="{get:aliens}" is="Definitely are green"]
This would match: http://www.example.com/?aliens=Definitely%20are%20green
[else]
This would NOT match: http://www.example.com/?aliens=Come%20in%20all%20colors
This would NOT match: http://www.example.com/?aliens-do-not-exist
[/gvlogic]Show a default value when the URL has none #
{get} has no default value. To open a page on a chosen value when the URL leaves the parameter out, put two embeds of the same View in a [gvlogic] pair. The first runs when {get:term} is empty, the second when it holds a value:
[gvlogic if="{get:term}" is=""]
[gravityview id="12" search_field="5" search_value="Fall"]
[else]
[gravityview id="12" search_field="5" search_value="{get:term}"]
[/gvlogic]Replace 12 with your View's ID and 5 with the ID of the field to search. If the View has a secret, add it to both embeds, as Using the [gravityview] shortcode explains. With no term in the URL, or ?term= with nothing after it, the page lists the Fall entries. With ?term=Spring, it lists the Spring entries.
How {get} displays values #
There are security issues displaying data passed via URL. Because of this, GravityView uses the esc_html() function to make sure the information is safe to display.
This prevents malicious code from being added to your website by hackers.
- URL data:
?lets-get-dangerous=<script>alert("better watch out")</script> - Merge tag:
{get:lets-get-dangerous} - Output: the page shows the same text,
<script>alert("better watch out")</script>, but the HTML holds<script>alert("better watch out")</script>, so the browser shows it as text and never runs it. To turn this escaping off, use thegravityview/merge_tags/get/esc_html/{url parameter name}filter listed under Available filters below.
{get} prints the value without URL encoding, and it takes no modifiers, so {get:term:urlencode} prints nothing.
Retrieving subkeys (the URL parameter is an array)
If you need to retrieve a parameter that has subkeys, you must separate the keys using a forward-slash ("/").
For instance, when using our Search Bar Widget to filter a Date field as a date range, the resulting URL is similar to this:
example.com/view/my-view/?filter_10[start]=10/15/2021&filter_10[end]=12/20/2022
You'll notice the parameters are the same (filter_10), but there are different subkeys ("start" and "end").
These subkeys can be retrieved using a forward-slash separator:
{get:filter_10/start} returns "10/15/2021"
{get:filter_10/end} returns "12/20/2022"
Displaying array data
The {get} merge tag shows URL parameter arrays as a comma-separated value:
- URL data:
?example[]=Example+One&example[]=Example+(with+comma)%2C+Two - Merge tag:
{get:example} - Output:
Example One, Example (with comma), Two
If you want to modify the "glue" used to connect the array values, you can use the related filter below.
Available filters #
Developers can change the output of the {get} merge tag.
gravityview/merge_tags/get/glue/Modify the glue used to convert an array of{get}values from an array to a stringstring$glueString used toimplode()$_GET values Default:,(a comma and a space)string$propertyThe current name of the $_GET parameter being combined
gravityview/merge_tags/get/esc_html/{url parameter name}Turns offesc_html()for the{get}merge tag. By default, all values passed through URLs are escaped for security reasons. To pass HTML in the URL, return false on this filter. We recommend leaving the escaping on.boolean$esc_htmlWhether to esc_html() the value. Default:true
gravityview/merge_tags/get/value/{url parameter name}Modify the value of the{get}replacement before being usedstring$valueThe value that will replace{get}string$textText that contains{get}(before replacement)array$formA Gravity Forms form arrayarray$entryGravity Forms entry array