RELEVANT PRODUCTS:
  • Optimizely X Web Experimentation
  • Optimizely X Web Personalization
  • Optimizely X Web Recommendations

This article will help you:
  • Create custom snippets for your Optimizely 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 collaborator role. If the custom snippet feature is enabled for your account, all collaborators can view all of 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's how to create a custom snippet for your projects:

  1. Navigate to Settings > Implementation and click Create Custom Snippet...

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

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

  3. Click Save.

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

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

Custom snippet settings 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 account by navigating to Account Settings > Snippets.

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.

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 for all of the projects included in a custom snippet to edit or archive the snippet.

Basic snippets cannot be archived.