Embed a Block

Embed code used in sandbox must be changed for production. The environment and block ID will be different for sandbox and production environments.

The following steps describe a generic overview of embedding a block. Not all blocks produce the same embed code. To embed a web component, see Embed an OAuth Web Component.

Blocks are embedded on your site using iframes. Why iframes?Closed

Nitro blocks use iframes to embed an HTML document on a web page with a link to our content in the "src" attribute. This HTML document renders completely separate from the parent page, basically serving as a window to the iframe page.

Because Nitro iframes are fully encapsulated from the parent page, CSS rules and JavaScript logic of the parent page cannot alter the functionality of the Nitro embed and the Nitro embed cannot alter the CSS rules and JavaScript logic of the parent page.

Iframes provide greater security when embedding content as the iframe does not give read/write control of the entire page to Nitro.

Once a block is embedded on your site, any changes made to the block in the Block Builder will automatically update the embedded block. The block's ID creates the connection between Nitro Studio and the embed code and sends changes directly to the block without additional development.

  1. Use the Block Builder to create a block and get its embed code.
  2. Add the embed code on your page where you want the block to display.
  3. Set the height and width of the iframe.
  4. Get a valid 2-legged (global scope) OAuth token. A single global scope token can be used to create any number of gamification tokens. The global scope token should never be exposed publicly.
  5. Request a 3-legged gamification token from the /gamification-token API endpoint using the global scope token in step 4 as the authorization bearer token in the request header.
  6. Make sure the block type and ID match the name and ID of the block you created in Nitro Studio.

Example URL

Copy
src="https://blocks.bunchball.com/embeds/recognitions/2eeba795-7435-4f99-0000-4b8c3d6457a3?token=8e2b705164cc40000dd9bc736363ce12c5b"

URL Parameters

Parameter

Description

Value

environment

The environment where the block was created and is pulling data from.

  • Production - blocks.bunchball.com
  • Sandbox - blocks.sandbox.bunchball.com

embeds

The Nitro repository that stores the blocks.

embeds

type

The name of the block type.

Block types include: recognitions and impact

block ID

An ID unique to the block.

The ID is generated by Nitro. Example: af513949-af37-427b-a596-caa49817E1e0

token

The access token received from a token request.

Set to populate the variable for the OAuth gamification token. Replace the parameter with a variable containing the 3-legged OAuth token at runtime.

language

A language code if your program is localized.

Set to populate the variable with a language code representing the user's locale. Replace the parameter with the user's language code at runtime.

Example Embed Code

Impact Block

Copy
<div style="width: 100dvw; height: 100dvh;overflow:hidden;border-radius:0">
    <iframe title="Impact" style="border: none; width: 100%; height: 100%;"
    style="border: none; width: 100%; height: 100%"
    src="https://blocks.bunchball.com/embeds/impact/ea9dd0a4-4f41-xxxx-0000-xxx8eec87c89?token=eyJraWQiOihI2dDeeCYNv4fqws3gNXmSA-Kg"></iframe>
</div>    

Recognitions Block

Copy
<div style="width: 485px; height: 650px">
  <iframe title="Recognitions"
    style="border: none; width: 100%; height: 100%"
    src="https://blocks.bunchball.com/embeds/recognitions/2eeba795-7435-4f99-0000-4b8c3b9e3?token=cdf0a422ABC123">
    </iframe>
</div>
        

See also

Blocks

Styling blocks

OAuth Client