Travis Bobier
 · Professional Nerd

Ceros SDK: Experience-level Commands Glossary

About this Guide

This article contains a glossary of Ceros SDK experience-level commands to use when writing your own SDK code. Please note that all listed commands are as is, and we cannot guarantee all functionality to work across all experiences and devices. 

getTitle

called on: CerosExperience arguments: none

Returns a string that contains the title of the Ceros experience.

var experienceTitle = experience.getTitle();

getCurrentPage()

called on: CerosExperience arguments:  none

Returns a CerosPage representing only the current page of the experience.

var page = experience.getCurrentPage();

getAllPages()

called on: CerosExperience arguments: none

Returns the ID of the current user viewing the experience as a string.

var userId = experience.getCurrentUserId();

getAllPages

called onCerosExperience arguments: none

Returns a CerosPageCollection representing all the pages of the experience.

var pageCollection = experience.getAllPages();
var thirdPage = pageCollection.pages[2];
thirdPage.disable();

findPageById(pageId)

called onCerosExperience argumentspageId – the SDK ID of the page to retrieve

Returns a CerosPage representing either the single page that has ID pageId, or null if the ID can not be found.

var myPage = experience.findPageById('a-page-id');
if (myPage){
    myPage.disable(); //disables the page, if it was found
}

findPagesByTag(tag)

called onCerosExperience argumentstag – a string

Returns a CerosPageCollection containing all pages in the experience that have been tagged with tag in the Studio.

var taggedPages = experience.findPagesByTag("foo");

goToPage(pageNum)

called onCerosExperience argumentspageNum – The number of the page to go to. Must be between 1 and the total number of pages in the experience, inclusive.

Navigates the experience to the page specified by pageNum. If pageNum is not a valid page in the experience, the command will do nothing.

experience.goToPage(3);

goToNextPage()

called onCerosExperience arguments: none

Navigates the experience to the page directly after the one the user is currently on. If the user is on the last page (if the experience is not a carousel), or if the experience only has one page, the command will do nothing.

experience.goToNextPage();

goToPreviousPage()

called onCerosExperience arguments: none

Navigates the experience to the page directly before the one the user is currently on. If the user is on the first page (if the experience is not a carousel), or if the experience only has one page, the command will do nothing.

experience.goToPreviousPage();

findAllSyncedObjects()

called onCerosExperience arguments: none

Returns a CerosSyncedObjectCollection. All syncedObjects in the experience are returned.

var syncedObjects = experience.findAllSyncedObjects();
syncedObjects.show(); //shows all syncedObjects in the experience

findSyncedObjectById(syncedObjectId)

called onCerosExperience argumentssyncedObjectId – the SDK ID of the syncedObject to retrieve

Returns a CerosSyncedObject representing either the single syncedObject that has ID syncedObjectId, or null if the ID can not be found.

var mySyncedObject = experience.findSyncedObjectById('a-syncedObject-id');
if (mySyncedObject){
    mySyncedObject.hide(); //hides the syncedObject, if it was found
}

findSyncedObjectsByTag(tag)

called onCerosExperience argumentstag – a string

Returns a CerosSyncedObjectCollection containing all syncedObjects in the experience that have been tagged with tag in the Studio.

var taggedSyncedObjects = experience.findSyncedObjectsByTag("foo");

findSyncedObjectsWithAnyTags(tags)

called onCerosExperience argumentstags – an array of strings

Returns a CerosSyncedObjectCollection containing all syncedObjects tagged with any of the tags passed in the tags array in the studio.

var taggedSyncedObjects = experience.findSyncedObjectsWithAnyTags(["foo","bar"]);

findSyncedObjectsWithAllTags( tags )

called onCerosExperience argumentstags – an array of strings

Returns a CerosSyncedObjectCollection containing all syncedObjects tagged with all of the tags passed in the tags array in the studio.

var taggedSyncedObjects = experience.findSyncedObjectsWithAllTags(["foo","bar"]);

findAllLayers()

called onCerosExperience arguments: none

Returns a CerosLayerCollection. All layers in the experience are returned.

This includes layers within syncedObjects. Commands run on layers within syncedObjects apply to all uses of the syncedObject.

var layers = experience.findAllLayers();
layers.show(); //shows all layers in the experience

findLayerById( layerId )

called onCerosExperience argumentslayerId – the SDK ID of the layer to retrieve

Returns a CerosLayer representing either the single layer that has ID layerId, or null if the ID can not be found.

This will also fetch layers within syncedObjects by their SDK ID. Commands run on layers within syncedObjects apply to all uses of the syncedObject.

var myLayer = experience.findLayerById('a-layer-id');
if (myLayer){
    myLayer.hide(); //hides the layer, if it was found
}

findLayersByTag( tag )

called onCerosExperience argumentstag – a string

Returns a CerosLayerCollection containing all layers in the experience that have been tagged with tag in the Studio.

This includes layers within syncedObjects. Commands run on layers within syncedObjects apply to all uses of the syncedObject.

var taggedLayers = experience.findLayersByTag("foo");

findAllComponents()

called onCerosExperience arguments: none

Returns a CerosComponentCollection. All components in the experience are returned.

This includes components within syncedObjects. Commands run on components within syncedObjects apply to all uses of the syncedObject.

var layers = experience.findAllComponents();
components.show(); //shows all components in the experience

findComponentById( component-id )

called onCerosExperience argumentscomponent-id – the SDK ID of the component to retrieve

Returns a CerosComponent that represents the component with ID component-id. If there is no component with this ID, the command will return null.

This will also fetch components within syncedObjects by their SDK ID. Commands run on components within syncedObjects apply to all uses of the syncedObject.

var component = experience.findComponentById('a-component-id');

findComponentsByTag( tag )

called onCerosExperience argumentstag – a string

Returns a CerosComponentCollection containing all components in the experience that have been tagged with tag in the Studio.

This includes components within syncedObjects. Commands run on components within syncedObjects apply to all uses of the syncedObject.

var taggedComponents = experience.findComponentsByTag("foo");

findComponentsWithAnyTags( tags )

called onCerosExperience argumentstags – an array of strings

Returns a CerosComponentCollection containing all components tagged with any of the tags passed in the tags array in the studio.

This includes components within syncedObjects. Commands run on components within syncedObjects apply to all uses of the syncedObject.

var taggedComponents = experience.findComponentsWithAnyTags(["foo","bar"]);

on(eventName, callback)

called onCerosExperience argumentseventName – The name of the event to subscribe to callback – The function to run when this event is received

var pageChangedCallback = function(page){
  var payload = page.getPayload();
}
experience.on(CerosSDK.EVENTS.PAGE_CHANGED, pageChangedCallback);

See Events

setUserConsentForAnalytics(consent)

called onCerosExperience argumentsconsent – User consent (true/false)

Sends the user consent selection to the experience, which will save the user’s consent selection and enable or disable tracking cookies. This function does not return anything.

experience.setUserConsentForAnalytics(true);

getUserConsentForAnalytics( callback )

called onCerosExperience argumentscallback – Function to be called with the user consent value. This is a string with one of the following values:

“Consented” – When the user specifically consented to analytics tracking.
“Declined” – When the user specifically declined analytics tracking.
“Unknown” – When the user has not made a selection.

This function does not return anything, the consent value is passed to the callback.

myExperience.getUserConsentForAnalytics(function(consent) {
  switch (consent) {
    case 'Consented':
      // Do something if the user has consented
      break;

    case 'Declined':
      // Do something if the user has declined
      break;

    case 'Unknown':
      // Do something if the user has not made a selection
      break;
  }
});
1