Conditional content
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
Conditional content blocks let you control who can see a given block of content on your page based on user data and variables. These variables can be passed in via cookies, feature flags, authenticated access, or URL parameters.
To add a conditional block, begin a new line in the editor, type /, then select Conditional content.
After inserting the block, click the red condition badge in the top right of the block.
Clicking this will allow you to add a condition through the . You’ll be able to write your condition as an that will run against data defined in your site. You can reference data from , or data coming from visitors through their .
See
The examples below use a URL parameter linked from the button to control which conditional content block is visible.
This block is only visible to users without attribute A.
## Example
{% if visitor.claims.unsigned.example_attribute_A %}
This block is only visible to users **with** attribute A.
<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">View without attribute A</a>
{% endif %}
{% if !visitor.claims.unsigned.example_attribute_A %}
This block is only visible to users **without** attribute A.
<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">View with attribute A</a>
{% endif %}