How to

Preview scheduled CMS content

Preview scheduled and/or filtered CMS content for customers using Geins Merchant API

Prerequisites

  • Merchant API key
  • CMS content with future publish dates or specific filters

Goal

  • Preview scheduled CMS content before it goes live
  • Test content filtering based on attributes

Architecture at a glance

  • Get preview token → Use token in Merchant API requests → Access scheduled/filtered CMS content

APIs used

  • Merchant API: https://merchantapi.geins.io/graphql

Step-by-step

Obtain a preview token

Log in to your Geins Merchant Center (https://{ACCOUNT_NAME}.admin.geins.io) and navigate to the CMS section. Locate the content you want to preview and choose an option under the "View" dropdown menu. You will be routed to a url with the preview token in the query parameters; ?loginToken={YOUR_PREVIEW_ACCESS_TOKEN}. Use the token for the next step.

A way of getting a preview token via Management API is under development. For now, use the Merchant Center method described above.

Use the preview token in Merchant API requests

Now that you got your token, you can use it in your Merchant API requests to preview scheduled CMS content. Use the widget area filters/parameters to preview specific content (for example, set channelId to preview content for a specific channel).

In the example below, we're previewing startpage content for desktop users who viewing prices excluding VAT.

Try it out in the GraphQL Playground using the query, headers and variables below.

Request example

query widgetArea(
  $family: String = null
  $areaName: String = null
  $displaySetting: String = null
  $preview: Boolean = null
  $customerType: CustomerType
  $channelId: String
  $languageId: String
  $marketId: String
) {
  widgetArea(
    family: $family
    areaName: $areaName
    displaySetting: $displaySetting
    preview: $preview
    customerType: $customerType
    channelId: $channelId
    languageId: $languageId
    marketId: $marketId
  ) {
    tags
    containers {
      layout
      design
      widgets {
        name
        configuration
        images {
          fileName
        }
      }
    }
  }
}
The channelId, languageId, and marketId arguments are optional and can be left out to use default values.

Response example

200 OK
response.json
{
  "data": {
    "widgetArea": {
      "tags": [...],
      "containers": [
        {
          "layout": "...",
          "design": "...",
          "widgets": [
            {
              "name": "...",
              "configuration": "...",
              "images": [{
                  "fileName": "..."
              }]
            },
          ]
        }
      ]
    }
  }
}

Common pitfalls

  • Ensure the preview token is valid and not expired.
  • Use correct widget area parameters to filter content as needed.
  • Verify that the CMS content is properly scheduled and published in the CMS.
Related