Screen views and Documents inserts

Tip: If you use Visual Studio Code as your editor, you can use code snippets to speed up working with inserts.
You can find the snippets in our Github repository: https://github.com/Synerise/jinja-code-snippet

Common tags available in Screen Views and Documents

You can use all tags from Insert usage.

Recommendations

To add recommendations to Screen Views or Documents, use the recommendations_json3 insert as described in Inserting recommendations > Recommendations as JSON.

Documents

You can refer to a document in the following way:

{% document SLUG %}

In this case, you can’t pass custom parameters to the document you refer to.

Screen view collection

The {% screenviewcollection %} insert is added to a Screen View automatically when you create it in the Synerise Portal.

It inserts all the documents you added in the Documents to display section when configuring the Screen View.

Handling variables when displaying screen views/documents

Screen views and documents may include variables. These variables may be profile attributes (including analytics such as expressions) or variables that are not part of a profile.

If the non-profile variables aren’t declared in the screen view or document, they can be injected when making the request.

In Mobile SDKs

When a screen view/documents is displayed by using one of the Mobile SDK methods:

  • Values of inserts such as {% customer ATTRIBUTE_NAME %} or {% expression %} are fetched automatically from the profile authorized in the mobile app.
  • Variables that use non-profile data, such as {{ foo }}, need to be added to apiQuery.params when using the “Generate document with query parameters” and “Generate screen view with query parameters” methods:

In API

The API offers a number of endpoints to generate screen views and documents for display. They may require injecting profile attributes manually.

  • Data for variables in the {{ foo }} format must always be added to the request, unless those variables are declared in the document.
  • Data for inserts which insert profile attributes, such as {% customer ATTRIBUTE_NAME %} or {% expression %}:
    • Does NOT need to be added to requests with Profile authorization (example 1 below). The data is automatically fetched from the authorized profile.
    • Does NOT need to be added to requests which indicate a profile in their parameters (example 2 below). The data is automatically fetched from the indicated profile.
    • Needs to be added to requests Workspace/Synerise User authorization when they don’t indicate a profile (example 3 below).
Important: Some endpoints accept all types of authorization. In that case, you need to inject data for profile inserts only when authorizing as a Workspace/Synerise User.
/schema-service/v2/documents/{slug}/generate is an example of such an endpoint.

Examples

For the purpose of the examples below, assume the following document:

{
  "exampleCustomParameter": "{{ foo }}",
  "exampleExpression": "{% expression %}61722849-e004-48ef-a574-ee3702c88450{% endexpression %}",
  "exampleProfileAttribute": "{% customer email %}"
}

where:

  • {{ foo }} is a variable that’s not saved in the profile and not declared in the document.
  • {% expression %}61722849-e004-48ef-a574-ee3702c88450{% endexpression %} returns the result of an expression. For the profile in this example, it’s segment2.
  • {% customer email %} inserts the email parameter from a profile.

This is an example of “Generate document” request authorized with a Profile JWT. Profile attributes and the expression value are fetched automatically.

If you provide values for exampleProfileAttribute or exampleExpression, they are ignored.
Request:

curl --location 'https://api.synerise.com/schema-service/v2/documents/example-1/generate' \
--header 'Authorization: Bearer PROFILE_JWT' \
--header 'Content-Type: application/json' \
--data '{
    "foo": 12
}'

Output:

{
    "uuid": "98ed0cef-ed81-4fc7-83e8-638f2009174d",
    "slug": "example-1",
    "schema": "examples",
    "content": {
        "exampleCustomParameter": "12.0",
        "exampleExpression": "segment2",
        "exampleProfileAttribute": "example@synerise.com"
    }
}

API reference: /schema-service/v2/documents/{slug}/generate

Other endpoints with the same behavior:

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker