JavaScript API

Userlove JavaScript supports the following events & methods as part of its API

Examples

Identify the current user

userlove("identify", {
  id: "YOUR_USER_ID",
  userData: {
    name: "John Doe",
    email: "john@example.com",
  },
});

Track event

userlove("track", { event: "CustomEventName" });

Track event with custom data

userlove("track", {
  event: "CustomEventName",
  data: {
    name: "123456789",
    price: 299.99,
  },
});

Launch Product Tour

userloveMethods.launchProductTour("YOUR-TOUR-ID");

This function allows you to start a product tour anytime without verifying any trigger or segment conditions. You only need to pass the unique tour ID as a single argument to the function.

Hide Product Tour

userloveMethods.hideProductTour("YOUR-TOUR-ID");

You can use this function to dismiss a product tour or trigger the completed event. If the product tour is already completed, the function will fire the completed event. Otherwise, it will dismiss the product tour. You need to pass the unique Tour ID of that product tour as a single argument to this function.

Launch Survey

userloveMethods.launchSurvey("YOUR-SURVEY-ID");

This function can be used to launch a survey at any time, without checking the trigger or segment conditions. You only need to provide the survey ID, which you can copy from the survey list.

Hide Survey

userloveMethods.hideSurvey("YOUR-SURVEY-ID");

You can use this function to trigger a dismiss or completed event for a survey. When the function is called, if the survey is already completed and displaying a thank you screen, it will fire the completed event. In any other case, it will dismiss the survey. You only need to pass the unique survey ID as a single argument to the function.

Launch Onboarding Checklist

userloveMethods.launchChecklist("YOUR-CHECKLIST-ID");

This function can be used to start a checklist at any time, regardless of any triggers or segment conditions. You just need to provide the unique checklist ID as a single parameter.

Hide Onboarding Checklist

userloveMethods.hideChecklist("YOUR-CHECKLIST-ID");

This function triggers a dismiss event or a completed event for a checklist. If the checklist is already completed or displaying a congratulatory screen, calling this function will fire the completed event. Otherwise, it will dismiss the checklist. It required a single argument, which is the unique ID of the checklist.

Last updated