# Document

A widget `Document` lets you integrate a Page document into your product or website to deliver contextual education.

## Create a widget&#x20;

To create a Document widget, click on the New button in the top right-hand corner and then on Document. A drawer opens:&#x20;

* Choose the rendering mode for your widget:&#x20;
  * `Embed`: the widget appears as an embed and you can integrate it anywhere on your site or application.&#x20;
  * `Modal`: the widget is in a window opened with a button.&#x20;
  * `Drawer`: the widget is in a side panel opened with a button.
* Enter a `title`. :bulb: This title will not be visible in the widget integrated into your application.&#x20;
* Select a course using the search bar.
* Click on `Create`: that's it, your widget is ready to be integrated! :point\_right: [Find out more here.](https://help.meltingspot.io/english/manage-spot/widget/implementation)

<figure><img src="https://3055204660-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrzBxnWaSListMwx3rzKu%2Fuploads%2FRdSJKtkY1x4JGyMVOKq3%2Fimage.png?alt=media&#x26;token=37074c22-ebbe-420d-a7ba-86671cc6fa74" alt="" width="330"><figcaption></figcaption></figure>

## Edit a widget&#x20;

You can edit a widget in two different ways:&#x20;

* From the widget list, by clicking on the three small dots to the right of a widget's card and then on `Edit`.&#x20;
* From the widget preview window, click on `Edit`.&#x20;

### General tab

The widget drawer opens, where you can edit :&#x20;

* The widget's **rendering type**. <mark style="color:red;">**Warning**</mark>, switching your widget type requires you to update the code.
* The widget **title**&#x20;
* The **selected doucment**: simply click on the `X` button at the top right of the selected document and use the search bar to find the required document.

Once you've made all your changes, you can save the widget by clicking on `Save`.&#x20;

### Statistics tab

In the `Statistics` tab, you can access the usage data for your widget:

* The first box, `Widget Data`, provides usage statistics related to the widget as a whole:
  * `Views`: The number of times the widget has been viewed.
  * `Last updated`: The date the widget was last modified.
* In the second box (`Document Data`), you will find general data about the document:
  * `Last updated`: The date the document was last modified.

A `Open Document` button allows you to access the document in the Spot.

## Widget preview&#x20;

The widget preview depends on its rendering type:&#x20;

* If it's an `Embed` or `Modale` widget: When you click on a widget card, a window opens. In this window, you can see a preview of the widget's rendering in your application or site (in the case of an embed, grey zones materialize the content of your site).&#x20;
* If it's a `Drawer` widget: when you click on a widget's card, a side panel opens. Here you can see a preview of how the widget will look in your application or site.

At the bottom of the modal, there are several buttons:&#x20;

* `Get code`: gives you the choice between [sending](#recovering-code) the widget code directly by e-mail (with `Send instructions`) or [retrieving and copying](#recovering-code) the widget code (with `Copy code`).&#x20;
* `Edit`: opens the editing drawer.&#x20;

<figure><img src="https://3055204660-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrzBxnWaSListMwx3rzKu%2Fuploads%2FsODlhYp2tJVjIxun2yBj%2Fimage.png?alt=media&#x26;token=04ac6e06-b383-4966-8841-dc1488b4348b" alt="Preview of a modal widget" width="563"><figcaption><p>Preview of a modal widget</p></figcaption></figure>

## Widget display&#x20;

Many members of your site or application will be able to access your widget. Don't worry, they will only see the document if they have access to it.

To access a document,&#x20;

* The member must be logged in
* The member must have access to the collection containing the document (either because the collection is public, or because it is private, but the member is invited to the collection).
* The document must be published (unless the member is an admin or has "manage & create collections" permission).

{% hint style="success" %}
If a member displays the document widget and has access to it, the corresponding activity will be taken into account and you will be able to find it in the `Dashboard` page of your Spot settings.
{% endhint %}

**To ensure that the user sees the widget content while logged in, we recommend that you set up SSO authentication in the widget integration space.**

{% content-ref url="../sso" %}
[sso](https://help.meltingspot.io/english/manage-spot/sso)
{% endcontent-ref %}

{% hint style="info" %}
Once SSO has been set up, **the JWT token authenticating the user can be transmitted directly to the widget script**. Find out more [here](https://help.meltingspot.io/english/sso#embed-widgets--sso).
{% endhint %}

## Deleting a widget&#x20;

There are 2 ways to delete a widget:&#x20;

* From the widget card, click on the three small dots on the right, then on `Delete`.&#x20;
* From the widget editing drawer, click on the three small dots in the top right-hand corner, then on `Delete`.&#x20;

Clicking on either of these two buttons opens a confirmation window.&#x20;

{% hint style="danger" %}
**Warning**, all deletions are final!&#x20;
{% endhint %}

{% hint style="info" %}
If you delete a widget in your Spot settings, we recommend you also remove it in the code of your application or site - no worries if you forget, your members will only see an empty insert 😉
{% endhint %}
