Create a widget template

3

min

quiz

We offer a library of widgets to use into experiments. You can integrate these widgets inside your pages or above them. For more information on these predefined elements, read our documentation.

You can also create your own widget templates by coding them and use them in A/B tests and personalizations. This way you can make sure that the widgets perfectly fit your needs, as you create and customize them yourself. This expands testing and personalization possibilities.

NB : If you’re not comfortable with coding, use one of our ready-to-use widgets or ask your developer!

How to start the creation of a new template

To access the widget template interface, you must first be connected to the Kameleoon back office.

Pull down the “Configuration” menu and click on “Widget templates”:

At the top right of the page that has just opened, the “New template” gives access to the creation pop-in.

How to complete the creation pop-in

In the pop-in you can to name your template, associate a website and optionally write a description and add tags.

Then click on “Create” to go to the next step.

The template editor

The template editor is made up of three distinct areas.

Left panel

The title of your template is displayed at the top left. On hover, an edit icon appears. You can click on it to rename your template.

This panel also gives you access to the two essential steps of creating your template:

  • The code to be run
  • The user interface

With one click, you can switch from one to the other.

Content zone

In this area in the center you enter your template’s code.

Bottom panel

On the bottom left of the page, you will find a notification area. By default, it indicates the date and time of the last save. To its right are two action buttons:

  • The “Save” button that saves template edit as a draft. You stay in the editor.
  • The button “Activate” which validates the edition and actives the template. You leave the editor to return to the template management page.

NB : You don’t have to save when you switch tabs.

If you edit an existing and activated template, these two buttons become “Edit” (to save the modification of the draft) and “Finish” (to activate the modified template).

NB : If you leave the editor without saving your changes, a pop-in will ask you if you want to save your work.

How to code the template

The central content area is where you code your widget template. This code will be used on your website’s page to generate the widget. There are three tabs for three different kinds of code:

  • JS (JavaScript)
  • HTML
  • CSS

By default, it is empty and the active tab is the JavaScript one. Write your code directly into the blank area.

To validate your template, you must have entered at least 10 characters in the “JS” tab. JavaScript is sufficient to create your template. However, you can add HTML and/or CSS.

Once your code is written, click on “User Interface” in the left panel to access the user interface step.

Special case: the variable

To run a widget whose code must use a field (a variable) specified by the user when configuring the widget:

  • In the “User Interface” tab

Add the templateDataName = “XXX” attribute in the corresponding form field and replace XXX with a name.

Example:

<input id=”message” type=”text” templateDataName=”messageContent” placeholder=”Type your message”>

  • In the “Code to run” tab

To retrieve the corresponding variable, use the UserData.XXX syntax, where XXX is the name assigned in the user interface.

Example :

var userInput = userData.messageContent;

alert(userInput);

How to create the user interface

In the “User Interface” tab, the content area changes: only HTML and CSS are available. Click on one or the other and add your code.

By doing so, you code the form for the user interface, which users need to fill in to create a widget via this template. The form is displayed when the widget is added to an experiment.

If no user interface is provided for your widget, this part is optional and the fields can remain empty.

How to activate the template

To finalize the creation of your template and activate it, click on the “Activate” button at the bottom right of the editor page.

NB : If you have entered less than 10 characters in the JavaScript part of the editor, the button is grayed out and you can’t activate your template.

A sticky footer informs you that the template has been successfully activated:

That’s it, your template can be used to create a widget in an experiment!

A card is automatically created on the templates management page. You can find it there and modify it if necessary.

How to manage created templates

When you have created a template, it appears as a card on the “Widget templates” page, with the following information:

  • Name
  • Associated website(s)
  • Type (“personalized template”)
  • Status (draft, active or disabled)
  • Action icons (activate/deactivate, edit, duplicate, delete) on hover

You can also search, filter or sort your different templates.

 

When hovering over a card, several action icons appear:

  • Activate/Deactivate
  • Edit
  • Duplicate
  • Delete

  • If the template is active, a click on the icon  disables the template without deleting it from the library. You will be able to reactivate it later. A deactivated template will no longer appear in the list of available templates when creating an experiment.

If the template is not used in any active experiment

Deactivation takes place immediately.

If the template is used in an active experiment

A pop-in alert indicates that deactivation is impossible. Click on  to view the list of active experiments using this template.

  • If the template is disabled, you can click on the icon  to reactivate it. It is then available again into experiments.
  • The  icon enables you to edit the template’s parameters and code. A click opens a pop-in, similar to the new template creation one. If your template is used in an experiment, a pop-in opens upon validation of your changes informing you that the update can only apply to your personalizations and not your A/B tests, and asking you to confirm or cancel your choice. In the configuration menu of your personalization, a sticky footer also informs you on the template’s modification.
  • The  icon enables you to duplicate the template. A click opens a pop-in similar to the new template creation one. Click on the button to duplicate.
  • Finally, with . click on the  icon, you can remove the template, including all widgets using it. This action is irreversible.

If the template is not used in an experiment (no widget)

A pop-in asks you to confirm your choice or cancel it.

If the template is used in a disabled experiment

A pop-in informs you that this action is not recommended. Click on to view the list of disabled experiences using this template.

If the template is used in an active experiment

A pop-in informs you that this action is not possible. Click on to view the list of active experiences using this template.

How to use the widget in an experiment

Your template is created and activated? You can now use it in an A/B test or a personalization.

In an A/B test

Add a widget from the editor

Once your A/B test is created and opened in the editor, click on the name of your variation, then on “New Element”.

In the pop-in that opens, click on “Widgets”.

Select a widget template

In the list of widgets, click on “Personalized Widget”, select the name of the template you need in the drop down menu, then click on “Add”.

A drop down menu appears asking you to choose between a display in the page or above it.

Configure the template

Select the device(s) on which you want to display your widget.

If you have set up a user interface when creating your template, a form opens. Complete it to configure the widget, then click on “Save” at the bottom left to validate your configuration.

The widget is now added to your test! You can continue setting up your experience.

In a personalization

Select a type of personalization

On your customization setup page, choose a customization type: “In the content of your pages” or “Above your pages”.

Select a widget template

Click on “Personalized Templates”: the menu unfolds.

Select a personalized template by clicking on “Add”.

Then choose the device (s) on which you want to display your widget.

If you haven’t set a user interface, you’re done with the widget part. Continue tour personalization setup as usual.

Configure the template

If you have set up a user interface when creating your template, a form opens. Complete the information to configure the widget, then click on “Save” at the bottom left to validate your configuration.

Capture_d_e_cran_2018-07-04_a__16.42.28.png

The widget is now added to your customization! Continue setting up your experience.