Skip to content

Reference

Global SDK object

The hosted script exposes a global trainingkit object.

Methods

trainingkit.init(baseUrl)

Initializes the SDK with your TrainingKit base URL.

js
trainingkit.init('https://cloud.YourCompany.fizzup.com')

trainingkit.start(options)

Starts a workout session.

js
trainingkit.start({
  workoutId: '4RGZ7S46',
  soundpack: 'none',
  getAccessToken: async function () {
    return 'your-access-token'
  },
  onWorkoutQuit: function () {},
  onWorkoutSave: function (workoutData) {},
  onWorkoutEvent: function (action, payload) {},
})

Options

FieldRequiredDescription
workoutIdYesTrainingKit workout identifier to launch
soundpackNoSound theme for the workout experience
getAccessTokenNoAsync callback returning a backend-issued access token
onWorkoutQuitNoCallback called when the user quits the workout
onWorkoutSaveNoCallback called when workout data is saved
onWorkoutEventNoGeneric callback receiving event name and payload

Completion listeners

Register the workout listeners in the same trainingkit.start call that launches the workout:

js
trainingkit.start({
  workoutId: '4RGZ7S46',
  onWorkoutSave: function (workoutData) {
    // Persist the completed workout result.
  },
  onWorkoutQuit: function () {
    // The user exited before completing the workout.
  },
  onWorkoutEvent: function (action, payload) {
    // Forward TrainingKit analytics metadata if needed.
  },
})
ListenerTriggerPayload
onWorkoutSave(workoutData)The workout completed and produced session state.Workout result data to persist in your app or backend.
onWorkoutQuit()The user closed the workout without completing it.None.
onWorkoutEvent(action, payload)TrainingKit emitted a tracking event.Event name plus event properties.

trainingkit.close()

Closes the TrainingKit iframe.

js
trainingkit.close()

Supported soundpacks

Based on the current example flow:

  • none
  • zen
  • original
  • new
  • whistle