Create, view, and manage custom snippets in Optimizely Web Experimentation

  • Updated
  • Create custom snippets for your Optimizely Web Experimentation projects
  • View and manage custom snippets

Custom snippets allow you to decide what projects and pages go into your snippet. Custom snippet permissions are based on the collaborator role. If the custom snippet feature is enabled for your account, all collaborators can view your account's snippets and copy snippet codes.

Administrators can create, edit, and archive custom snippets for any project in their accounts.

Project Owners can create custom snippets for their projects. They can also edit and archive custom snippets—as long as they have owner permissions on all of the projects included in the snippet. For example, to edit or archive a custom snippet that includes multiple projects, a user must be a Project Owner for every project in the snippet.

Create a custom snippet

Here is how to create a custom snippet for your projects:

  1. If you want to include more than one project in your custom snippet, confirm that all of the projects you want to include are linked projects.

  2. Navigate to Settings > Implementation and click Create Custom Snippet...
    create-custom-snippet.png

    Administrators can also access custom snippets by navigating to Account Settings > Snippets and clicking Create Custom Snippet...

    admin-custom-snippets.png

  3. In the Create Custom Snippet dialog, specify the settings you want for the snippet.
    See Custom snippet option below for more information about the settings you can choose.

  4. Click Save.
    save-custom-snippet.png

When you create a custom snippet, the project you are currently in is included in the custom snippet by default.

For custom snippets, integration and project JavaScript settings are not explicitly defined. Instead, they are inherited from the project the custom snippet pulls from.

Custom snippet options

  • Name: User-friendly name for the custom snippet; appears in the dashboard and elsewhere in the UI

  • Key: Unique snippet identifier that's included in the snippet URL; must be unique to the account https://cdn.optimizely.com/public/[account_id]/s/[developer_key].js

  • Description: Optional summary of how the snippet is generated and where it will go

  • Type: Choose whether the snippet is for a single project or for linked projects

Sources

  • Project: Specific projects the snippet should pull from (for linked projects); default is a single-project snippet for the current project

  • Pages: Pages to include and exclude from the snippet (default is to include all pages in the project)

    • Include URL and Exclude URL: URLs to include, exclude, or both (depending on your Pages selections)

    • Matching criteria: match to URL (snippet will include or exclude the specified URL) or match to substring (snippet will include or exclude any page that matches the specified substring); see Custom snippet matching criteria for details

Settings

View and manage custom snippets

Administrators can view and manage all custom snippets for their accounts by navigating to Account Settings Snippets.

admin-snippets-2.png

All collaborators can view snippets for the current project by navigating to Settings Implementation. As long as the project has at least one custom snippet, you'll see a dashboard that lists all basic and custom snippets that are associated with the project.

list-snippets-1.png

Administrators and Project Owners can click a custom snippet name to edit the snippet settings. They can also archive custom snippets by clicking the  icon. Remember, Project Owners must be owners of all projects included in a custom snippet to edit or archive the snippet.

archive-snippet.png

Basic snippets cannot be archived.