Skip to content

Types and enums#

This page lists the enums, content URL types, event data, tile data, ad request data, followed category types, theme classes, and server rendering helpers that the SDK exports. Theme properties are covered in Customize themes, and event properties in the analytics event pages.

Enums#

Every enum value is a string equal to its member name. In TypeScript, pass the enum member, such as Storyteller.UiStyle.dark. In JavaScript, you can also pass the string, such as 'dark'.

UiStyle#

enum UiStyle {
  auto = 'auto',
  light = 'light',
  dark = 'dark',
}

Selects the light or dark theme of a UiTheme. auto follows the system color scheme. Set it with configuration.uiStyle or the data-ui-style container attribute. See uiStyle.

CellType#

enum StorytellerListViewCellType {
  round = 'round',
  square = 'square',
}

Exported as CellType. Sets the tile shape of a row. The default is square. See cellType.

ActivityType#

The type argument of onUserActivityOccurred. The event pages list when each event fires and its properties:

Area Values Reference
SDK sdkInitialized SDK initialization
Lists tileVisible Tile visibility
Stories and Clips actionButtonTapped, shareButtonTapped, shareSuccess Story events, Clip events
Stories openedStory, dismissedStory, skippedStory, completedStory, openedPage, previousPage, previousStory Story events
Story captions enabledStoryCaptions, disabledStoryCaptions Story caption events
Polls votedPoll Poll events
Quizzes triviaQuizQuestionAnswered, triviaQuizCompleted Quiz events
Ads openedAd, dismissedAd, pausedAdPage, resumedAdPage, finishedAd, skippedAd, adActionButtonTapped, viewedAdPageFirstQuartile, viewedAdPageMidpoint, viewedAdPageThirdQuartile, viewedAdPageComplete Ad events
Clips openedClip, dismissedClip, finishedClip, nextClip, previousClip, completedLoop, clipVideoHeartbeat, clipVideoQuartile, scrubbedClip, mutedClip, unmutedClip, pausedClip, resumedClip, likedClip, unlikedClip, openedCategory, dismissedCategory, followableCategoryTapped Clip events
Clip captions enabledClipCaptions, disabledClipCaptions Clip caption events
Category follows followCategory, unfollowCategory, followableCategoryLimitShown, followableCategoryLimitActionButtonTapped, followableCategoryLimitDismissed Category follow events

The followableCategoryLimitShown, followableCategoryLimitActionButtonTapped, and followableCategoryLimitDismissed events reach onUserActivityOccurred only. The SDK doesn't send them to Storyteller analytics.

Version 11.1.0 added tileVisible, clipVideoHeartbeat, clipVideoQuartile, scrubbedClip, mutedClip, unmutedClip, followableCategoryTapped, followCategory, unfollowCategory, and the three followableCategoryLimit events. Update exhaustive switch statements over ActivityType.

These values are deprecated or unused:

  • completedPage and skippedPage are deprecated. The Story player still records them, but the event pages don't list their fields
  • swipedUp, viewedPage, completedAd, swipedUpOnAd, previousAd, impression, readyToPlay, mediaStarted, bufferingStarted, bufferingEnded. The SDK does not record these events

OpenedReason#

The openedReason property of open events:

Area Values
Stories storyListTap, deepLink, swipe, automaticPlayback, tap
Clips clipListTap, categoryListTap, categoryBackTap, deepLink, reloadMethod

See OpenedReason for each value. openCollection accepts OpenedReason.deepLink as its third argument. Without it, the first Clip reports deepLink, unless the open lands on a Category (destination.categoryId): then it reports categoryListTap. With it, a Category open reports deepLink too. openDeepLink always reports deepLink.

Version 11.1.0 added reloadMethod, which Clips events report after a feed reloads. Update exhaustive switch statements over OpenedReason.

DismissedReason#

The dismissedReason property of dismiss events:

Area Values
Stories and Clips backgroundTapped, instanceMethod, windowUnload
Stories closeButtonTapped, swipedDown, swipedFirstStory, swipedFinalStory, skippedFinalPage, completedFinalPage, backTapped, escapeKeyPressed
Clips backButtonTapped

See DismissedReason for each value. dismissPlayer reports instanceMethod, and puts the reason you pass it in customDismissedReason.

StorytellerTrackedFunctionalFeature#

enum StorytellerTrackedFunctionalFeature {
  all = 'all',
  clipLikes = 'clipLikes',
  clipShares = 'clipShares',
  clipViewedStatus = 'clipViewedStatus',
  pageReadStatus = 'pageReadStatus',
  pollVotes = 'pollVotes',
  triviaQuizAnswers = 'triviaQuizAnswers',
}

The items of eventTrackingOptions.disabledFunctionalFeatures. all disables every item. See Disabled functional features.

Note

The npm package exports this enum at runtime. The CDN script does not, so Storyteller.StorytellerTrackedFunctionalFeature is undefined there. Pass the string values instead, such as ['pageReadStatus'].

Theme enums#

Three enums set theme properties. See Customize themes for each property:

Enum Values Theme properties
Alignment start, center, end storyTiles.title.alignment, storyTiles.rectangularTile.chip.alignment
ButtonAlignment left, center, right player.actionButton.alignment
TextCase default, upper, lower buttons.textCase

Privacy options#

The type of Storyteller.sharedInstance.eventTrackingOptions.

StorytellerEventTrackingOptions#

type StorytellerEventTrackingOptions = {
  disabledFunctionalFeatures: StorytellerTrackedFunctionalFeature[];
  enableAdTracking: boolean;
  enableFullVideoAnalytics: boolean;
  enableFunctionalCookies: boolean;
  enablePersonalization: boolean;
  enableRemoteViewingStore: boolean;
  enableStorytellerTracking: boolean;
  enableUserActivityTracking: boolean;
};
Field Default Effect when changed from the default
disabledFunctionalFeatures [] Stops tracking the listed features
enableAdTracking true false stops ad events and removes Story and Clip details from ad requests
enableFullVideoAnalytics true false sets Story, Page, and Clip IDs and titles to null in callback data
enableFunctionalCookies true false stops non-essential local storage, and turns off personalization and Storyteller tracking
enablePersonalization true false stops sending user IDs and user attributes for personalization
enableRemoteViewingStore true false keeps user IDs off backend services and keeps viewing activity on the device
enableStorytellerTracking true false stops storing analytics events on Storyteller servers
enableUserActivityTracking true false stops onUserActivityOccurred calls

Content URLs#

parseDeepLink(url: string): DeepLink | null

Reads a Storyteller content URL or player hash and returns its destination as a DeepLink. It makes no requests and doesn't change the page. Call it as Storyteller.parseDeepLink, or import it by name.

Parameter Type Required Default Description
url string Yes None A Storyteller content URL, or a player hash such as #clips/collection-id
const deepLink = Storyteller.parseDeepLink(
  'https://storyteller.com/go/clip?collectionId=collection-id&feed=following'
);
// { type: 'collection', collectionId: 'collection-id', initialFeed: 'following' }
  • Returns: the destination, or null for an unsupported or malformed URL
  • Since: 11.1.0
  • Guide: Supported URL formats

To open the destination, pass the same URL to openDeepLink.

type DeepLink =
  | { type: 'story'; storyId: string; categoryId?: string }
  | { type: 'storyExternalId'; externalId: string }
  | {
      type: 'page';
      pageId: string;
      fallbackStoryId: string;
      answerId?: string;
      categoryId?: string;
    }
  | { type: 'category'; categoryId: string }
  | {
      type: 'clip';
      clipId: string;
      collectionId?: string;
      initialFeed?: ClipFeed;
    }
  | {
      type: 'clipExternalId';
      externalId: string;
      collectionId?: string;
      initialFeed?: ClipFeed;
    }
  | {
      type: 'clipCategory';
      categoryId: string;
      collectionId?: string;
      initialFeed?: ClipFeed;
    }
  | {
      type: 'collection';
      initialFeed?: ClipFeed;
      collectionId: string;
      clipId?: string;
      categoryId?: string;
    };

The result of parseDeepLink. Check type to find the destination. The parser URL-decodes each ID once, so an ID that was encoded twice keeps one level of encoding.

  • Pages: the result keeps the link's answerId. openDeepLink opens the Page. When the Page can't load and the link has no categoryId, it opens the fallbackStoryId Story instead
  • Categories in hashes: Story and Page hashes name the category with the categoryId query parameter, and collection hashes with category. When a hash names both content and a category, openDeepLink keeps both. It rejects when a Story isn't in that category
  • Clip categories: openDeepLink rejects a clipCategory link without a collectionId
  • Starting feed: initialFeed is 'following' when the URL has feed=following. The parameter name and value ignore case. When openDeepLink opens the link, a Clip or category in it takes priority over initialFeed

See supported URL formats.

  • Since: 11.1.0

OpenDeepLinkOptions#

type OpenDeepLinkOptions = { context?: unknown };

The options of openDeepLink. context is your own placement data for the events of this opening. It replaces the context configured on the view that opens the content. When you leave it out, the events carry the view's configured context. Events from a player that the SDK creates, because no view on the page has the content, carry none. The SDK passes context only to your callbacks.

  • Since: 11.1.0

Event data#

The data types of analytics events.

UserActivityData#

The data argument of onUserActivityOccurred. Every field is optional, and each event sets a subset. The event pages list the fields of each event.

Area Fields and types
Context context (unknown): the view's configuration.context
Stories and Pages storyId, storyTitle, storyDisplayTitle, pageId, pageTitle (string, or null when enableFullVideoAnalytics is false); storyIndex, storyPageCount, pageIndex, durationViewed, pagesViewed, contentLength (number); storyReadStatus (string); storyPlaybackMode ('list' or 'singleStory'); pageType ('image', 'video', 'poll', or 'triviaQuiz'); pageHasAction (boolean); pageActionText, pageActionUrl (string or null)
Navigation openedReason (OpenedReason); dismissedReason (DismissedReason); customDismissedReason (string, the reason passed to dismissPlayer); shareMethod ('share', 'shareMedia', 'shareLink', or '')
Categories categories (string[]); categoryDetails (CategoryDetail[]); currentCategory (CurrentCategory); categoryId, categoryName, categoryType (string)
Ads adId, adStrategy (string); advertiserName (string or null); adType ('stories' or 'clips'); adPlacement ('betweenClips', 'betweenStories', 'betweenStoriesAndPages', or 'betweenPages')
Polls pollAnswerId (string)
Quizzes triviaQuizId, triviaQuizQuestionId, triviaQuizAnswerId, triviaQuizTitle (string); triviaQuizScore (number)
Clips clipId, clipTitle (string, or null when enableFullVideoAnalytics is false); collection (string); clipActionText, clipActionUrl (string or null); clipIndex, clipsViewed, loopsViewed (number); clipHasAction (boolean); clipFeedType (ClipFeedType: 'default', 'forYou', or 'following'), also set on Clip ad events
Captions captionsEnabled (boolean)
Clip action taps actionClass ('primary' or 'secondary'); actionIndex (number, present for secondary actions only)
CMS metadata metadata (Record<string, string> or null): Story and Clip tile metadata, and active Clip metadata on player callbacks
List tiles tileIndex (number)
Category follows categoryType, location (string); followableCategoryLimitDialogue, followableCategoryLimitActionText, followableCategoryLimitActionUrl (string or null)
SDK initialization initializationSucceeded, enableAdTracking, enableFullVideoAnalytics, enablePersonalization, enableRemoteViewingStore, enableStorytellerTracking, enableUserActivityTracking (boolean); appId, screenResolution (string or null); deviceBrand, deviceModel, operatingSystem, osVersion (string); deviceType ('Phone', 'Tablet', 'TV', or 'Desktop')

On a Clip action tap, clipActionText and clipActionUrl describe the button the user tapped. actionIndex is the button's one-based position among the secondary actions set in the CMS. A Clip with one secondary action reports 1.

shareMethod is the Page's share setting from the Storyteller CMS. With 'share' or 'shareMedia', the Story player downloads the Page's media file. With 'shareLink', it shares a link to the Page. Clip share events report ''.

The SDK passes actionClass, actionIndex, and Clip CMS metadata only to your callbacks. It doesn't add them to the events it sends to Storyteller. See Clip metadata for when metadata is absent, empty, or null.

The category types have these fields:

class CategoryDetail {
  name: string;
  id?: string;
  type: string;
  placement?: string;
  externalId?: string;
}

class CurrentCategory {
  title: string;
  id?: string;
  placement?: string;
}

Clip playback events also use these optional fields: quartile?: 25 | 50 | 75, startPosition?: number, endPosition?: number, scrubDirection?: 'forward' | 'backward', completionType?: 'natural', and isMuted?: boolean. Seek positions and the heartbeat durationViewed are in milliseconds. See Clip events for when each event fires.

The SDK exports UserActivityData as a class. The callback receives a plain object with these fields.

ClipFeedType#

type ClipFeedType = 'default' | 'forYou' | 'following';

The type of clipFeedType on Clip and Clip ad events: forYou or following in a Clips player with the For You and Following tabs, and default in any other player. See Clip feed type.

  • Since: 11.1.0

ClipFeed#

type ClipFeed = Exclude<ClipFeedType, 'default'>; // 'forYou' | 'following'

A feed of a Clips player with the For You and Following tabs. It is the type of initialFeed in Clips player configuration, in the openCollection destination, and in DeepLink.

  • Since: 11.1.0

ActivityEventDetail#

class ActivityEventDetail {
  type: ActivityType;
  data: UserActivityData;
  constructor(type: ActivityType, data: UserActivityData);
}

A pair of event type and event data. The SDK exports the class, but no SDK callback receives it in 11.1.0.

List tile data#

StorytellerTileData#

The tile argument of onTileTapped. It is a StorytellerStoryTileData for a Story tile and a StorytellerClipTileData for a Clip tile. Check type to tell them apart.

type StorytellerTileData = StorytellerStoryTileData | StorytellerClipTileData;

interface StorytellerStoryTileData {
  type: 'story';
  storyId: string;
  storyTitle: string;
  tileIndex: number;
  categories: string[];
  categoryDetails: CategoryDetail[];
  metadata: Record<string, string> | null;
}

interface StorytellerClipTileData {
  type: 'clip';
  clipId: string;
  clipTitle: string;
  collection: string;
  tileIndex: number;
  categories: string[];
  categoryDetails: CategoryDetail[];
  metadata: Record<string, string> | null;
}
Field Description
storyTitle, clipTitle The Story's internal title, or the Clip's title
collection The Clip collection the list shows, or the Clip's own collection
tileIndex The tile's one-based position in the list
categories The names of the content's categories
categoryDetails The content's categories, as in UserActivityData
metadata Key-value metadata set in the Storyteller CMS, or null when the API sends none
  • Since: 11.1.0

Ad request data#

The adRequestInfo argument of getAdConfig and getBottomBannerAdConfig, and the bottom banner configuration. See AdRequestInfo.

StorytellerAdRequestInfo#

type StorytellerAdRequestInfo =
  | StorytellerStoriesAdRequestInfo
  | StorytellerClipsAdRequestInfo;

Check for the story field to tell the variants apart:

const isStoryAd = (
  info: Storyteller.StorytellerAdRequestInfo
): info is Storyteller.StorytellerStoriesAdRequestInfo => 'story' in info;

StorytellerStoriesAdRequestInfo#

type StorytellerStoriesAdRequestInfo = {
  placement: string;
  categories: string[];
  story: {
    id: '';
    categories: CategoryDetail[];
  };
};
Field Description
placement Placement code of the Story category that matches the first category ID of the view. '' when none matches
categories Category IDs of the view that shows the Story
story.categories Categories of the Story, as CategoryDetail objects. Their placement is the placement title, not the code
story.id Always ''. Deprecated

See Stories AdRequestInfo.

StorytellerClipsAdRequestInfo#

type StorytellerClipsAdRequestInfo = {
  collection: string;
  clip: {
    id: '';
    categories: ClipCategory[];
  };
  nextClip?: {
    categories: ClipCategory[];
  };
};
Field Description
collection Collection ID
clip.categories Categories of the current Clip
nextClip.categories Categories of the next Clip. nextClip is absent when no next Clip exists
clip.id Always ''. Deprecated

The SDK also calls getAdConfig with an empty clip.categories and no nextClip, to check that you return a config with a slot before it places Clip ads. Make your callback handle an empty list.

ClipCategory has these fields:

interface ClipCategory {
  id: string;
  name: string;
  externalId: string;
  placement: string | null;
  type: string;
  displayTitle: string;
  availableForNavigation: boolean;
  action?: IClipAction | null;
  categoryTypeCode?: string | null;
  description?: string | null;
  isFollowable?: boolean;
  showInClips?: boolean;
  thumbnailUrl?: string | null;
}
Field Description
id Storyteller's ID for the category
name Category name
externalId Category external ID, the ID you use in view configuration and ad targeting
placement Placement of the category, or null
type Category type, such as team
displayTitle The title shown to users
availableForNavigation true when the Clips player can list the category as a Category that the user opens
action What the follow control's image opens in place of the category's Clips: a web or in-app action, or nothing. IClipAction isn't exported by name
categoryTypeCode The category's type code, such as publisher
description Category description
isFollowable true when Storyteller marks the category as followable
showInClips true for the category that the Clip shows with its follow control
thumbnailUrl Category image URL

The optional fields are present when Storyteller sends them.

See Clips AdRequestInfo.

StorytellerBottomBannerAdRequestInfo#

type StorytellerBottomBannerAdRequestInfo =
  StorytellerClipsAdRequestInfo & {
    placement: 'Bottom Banner';
    slotType: 'bottomBanner';
  };

The adRequestInfo argument of getBottomBannerAdConfig.

Field Description
placement Always 'Bottom Banner'
slotType Always 'bottomBanner'
collection Collection ID of the feed
clip.categories Categories of the Clip, as ClipCategory objects
clip.id Always ''

The SDK never sets nextClip in this request info.

BottomBannerAdConfig#

interface BottomBannerAdConfig {
  type?: 'doubleclick';
  slot: string;
  size: [number, number] | [number, number][];
  customTargeting?: AdTargeting;
}

The return value of getBottomBannerAdConfig: a Google Ad Manager display unit for the Clips bottom banner. AdTargeting is the same type that getAdConfig uses.

Field Type Required Description
slot string Yes Ad unit path, in the form /[NETWORK_CODE]/[UNIT_CODE]. Use a banner unit, not the unit of your fullscreen ads
size [number, number] or [number, number][] Yes One [width, height] in CSS pixels, or every size the unit accepts, such as [[320, 50], [300, 50]]. Widths and heights are positive whole numbers, and heights are at most 80
customTargeting AdTargeting No Key-value pairs for the banner request. They override the SDK keys stCollection and stClipCategories. The SDK drops them when enableAdTracking is false
type 'doubleclick' No Ad server type. If you set it, it must be 'doubleclick'

The config needs a slot and a size. The SDK shows no banner when slot is empty, when any size isn't valid, or when you set type to a value other than 'doubleclick'.

Followed categories#

The types of getFollowableCategories and categoryFollowActionTaken. Version 11.1.0 added them. They exist only in TypeScript. See Followed categories.

StorytellerFollowableCategories#

interface StorytellerFollowableCategories {
  categories: StorytellerFollowableCategory[];
}

The result of getFollowableCategories. categories lists the categories that your tenant lets users follow.

StorytellerFollowableCategory#

interface StorytellerFollowableCategory {
  id: string;
  name?: string;
  displayTitle?: string;
  externalId?: string;
  type?: string;
  placement?: StorytellerPlacement;
  thumbnailUrl?: string;
  isFollowed: boolean;
}

The optional fields are present when Storyteller provides them.

Field Description
id Category ID
name Category name
displayTitle The title shown to users
externalId Category external ID
type The category's type code, such as team, player, or a custom type like publisher
placement The category's placement, as a StorytellerPlacement
thumbnailUrl Category image URL
isFollowed true when the current user follows the category. The check includes the type, so two categories with the same external ID but different types stay independent

See List followable categories.

StorytellerPlacement#

interface StorytellerPlacement {
  title: string;
  code: string;
}

The placement of a StorytellerFollowableCategory: the placement's title and code.

StorytellerCategory#

interface StorytellerCategory {
  externalId: string;
  name: string;
  displayTitle: string;
  type: string;
  placement: string | null;
  description?: string;
}

The category argument of categoryFollowActionTaken: the category that the user followed or unfollowed in the Clips player.

Field Description
externalId Category external ID. Save it to your own list of followed categories
name Category name
displayTitle The title shown to users
type Category type, such as team
placement The category's placement, or null
description Category description, when the category has one

See Follow categories in the Clips player.

Theme classes#

The classes and types that build a theme. Customize themes lists every theme property and default.

UiTheme#

class UiTheme implements IUiTheme {
  light: StorytellerTheme;
  dark: StorytellerTheme;
  constructor(baseTheme?: Subset<IUiTheme> | null);
}

Holds a light and a dark Theme. The constructor builds both from baseTheme, and unset properties keep their defaults. The view's UiStyle decides which theme applies. See Customize themes.

const theme = new Storyteller.UiTheme({
  light: { colors: { primary: '#1C62EB' } },
  dark: { colors: { primary: '#6699FF' } },
});

Theme#

class StorytellerTheme implements IStorytellerTheme {
  colors: StorytellerColorsTheme;
  font: string;
  primitives: StorytellerPrimitivesTheme;
  lists: StorytellerListsTheme;
  storyTiles: StorytellerTilesTheme;
  player: StorytellerPlayerTheme;
  clipPlayer: StorytellerClipPlayerTheme;
  buttons: StorytellerButtonsTheme;
  instructions: StorytellerInstructionsTheme;
  engagementUnits: StorytellerEngagementUnitsTheme;
  isDark: boolean;
  constructor(theme?: Subset<IStorytellerTheme>);
  toPlainObject(): this;
}

Exported as Theme. One color scheme of a theme. The constructor copies the properties of theme over the defaults. The SDK sets isDark when it builds the dark theme. toPlainObject() returns the same instance, not a copy.

Property Theme section
colors Colors
font Font
primitives Primitives
lists Lists
storyTiles Story Tiles
player Player
clipPlayer Clips player
buttons Buttons
instructions Instructions
engagementUnits Polls and Quizzes theme

Subset#

type Subset<K> = {
  [attr in keyof K]?: K[attr] extends object
    ? Subset<K[attr]>
    : K[attr] extends object | null
    ? Subset<K[attr]> | null
    : K[attr] extends object | null | undefined
    ? Subset<K[attr]> | null | undefined
    : K[attr];
};

A recursive Partial. Theme inputs use it, so you set only the properties that you change, at any depth.

const rowTheme: Storyteller.Subset<Storyteller.UiTheme> = {
  light: { lists: { row: { startInset: 0 } } },
};

Server rendering#

These exports build Story markup for server-side rendering. They do not use window or document.

ServerRenderer#

ServerRenderer.getStories(categories?: string[]): Promise<ServerRenderedStory[]>
ServerRenderer.render(stories: ServerRenderedStory[]): React.JSX.Element

A singleton instance. getStories loads the Stories of the given categories with the API key from initialize. It keeps only Stories that have a Web Story URL: a standalone page for the Story in Google's Web Stories format. render returns a hidden <amp-story-player> element, the AMP element that embeds Web Stories, with a link, poster image, and title for each Story. No task guide covers these methods.

Parameter Type Required Default Description
categories string[] No [] Story category IDs
stories ServerRenderedStory[] Yes None Stories from getStories

ServerRenderedStory#

type ServerRenderedStory = {
  id: string;
  href: string;
  title: string;
  thumbnailUrl: string;
};

href is the Story's Web Story URL, the standalone page for the Story in Google's Web Stories format.

Other exports#

The SDK also exports these names. No guide covers them, and integrations do not need them:

Export Kind Notes
Story Class Story data model from the Stories API. No public SDK method or callback returns it in 11.1.0
QuizRenderer Instance Renders Quiz questions and results inside a Story page document. The SDK's Story page script uses its own copy
QuizApiService Instance Loads Quiz data for Story pages. The SDK's Story page script uses its own copy