Get container

JSON LD Integration for SEO/GEO

Node.js + Express integration example

Add the jsonLd=true query parameter to your existing container API call, then inject
the returned block into your page's <head>.

const express = require('express');
const app = express();

app.get('/', async (req, res) => {
    // Fetch the container from the JOIN Stories API with JSON-LD enabled
    const apiResponse = await fetch(
        'https://api.stories.studio/v3/teams/MY_TEAM_ID/containers/MY_CONTAINER_ALIAS?jsonLd=true'
    );
    const data = await apiResponse.json();

    // Serialize the JSON-LD block into a <script> tag if present
    const jsonLdScript = data.jsonLd
        ? `<script type="application/ld+json">${JSON.stringify(data.jsonLd)}</script>`
        : '';

    res.send(`
        <!DOCTYPE html>
        <html>
            <head>
                <title>My products page</title>
                ${jsonLdScript}
            </head>
            <body>
                <h1>My products page</h1>

                <!-- JOIN Stories widget -->
                <div id="join-widget-MY_CONTAINER_ALIAS" style="display:block;"></div>
                <script
                    src="https://widget.stories.studio/widgets/MY_CONTAINER_ALIAS/index.js"
                    data-join-widget-id="join-widget-MY_CONTAINER_ALIAS"
                    data-join-widget-alias="MY_CONTAINER_ALIAS"
                    type="text/javascript"
                ></script>
            </body>
        </html>
    `);
});

Note: jsonLd is only included in the response when using API version v3
and payloadType is not set to sdk.

Language
Response
Click Try It! to start a request and see the response here!