FXM JavaScript API
Sitecore Federate Experience Manager (FXM) offers a JavaScript API that enables you to manage some of the Sitecore analytics functionality on webpages on external websites. To use this API, you must set up the FXM JavaScript beacon on the external website.
trackEvent
Use the trackEvent function to trigger a Sitecore page event from a webpage on the external website:
-
To trigger the Page visited page event:
SCBeacon.trackEvent(âPage visitedâ) -
To trigger the page event with additional parameters, such as
dataanddataKey:SCBeacon.trackEvent(âPage visitedâ, { data: âcustom dataâ, dataKey: âcustom data keyâ }) -
To trigger the page event with custom parameters, make sure the parameter starts with the prefix,
x. The custom parameter is added to the Text property. For example:SCBeacon.trackEvent(âPage visitedâ, { data: âMyDataâ, dataKey: âMyDataKeyâ, xKey1: âValue1â, xKey2: âValue2â })
trackGoal
Use the trackGoal function to trigger a Sitecore goal from a webpage on an external website:
-
To trigger the Register goal:
SCBeacon.trackGoal(âRegisterâ) -
To trigger a goal with additional parameters, such as
dataanddataKey:SCBeacon.trackGoal(âRegisterâ, { data: âcustom dataâ, dataKey: âcustom data keyâ }) -
To trigger the
SCBeacon.trackGoalgoal with custom data parameters, make sure the parameter starts with the prefix,x. The custom parameter is added to the Text property. For example:SCBeacon.trackGoal(âRegisterâ, { data: âMyDataâ, dataKey: âMyDataKeyâ, xKey1: âValue1â, xKey2: âValue2â })
trackOutcome
To use the trackOutcome function, you must use the item ID or name of a predefined outcome definition item, for example, Product Purchase:
SCBeacon.trackOutcome(â{9016E456-95CB-42E9-AD58-997D6D77AE83}â)SCBeacon.trackOutcome(âProduct Purchaseâ)
Use the trackOutcome function to trigger a Sitecore outcome from a webpage on an external website:
-
To associate the outcome with a monetary value, add the parameter
monetaryValueto thetrackOutcomefunction:SCBeacon.trackOutcome(â{9016E456-95CB-42E9-AD58-997D6D77AE83}â, { monetaryValue: â25,5â }) -
To trigger an outcome with custom data parameters, add the parameters to the
trackOutcomefunction. Make sure the parameters start with the prefix,x. For example:SCBeacon.trackOutcome(â{9016E456-95CB-42E9-AD58-997D6D77AE83}â, { xKey1: 'Key1Value', xKey2:'Key2Value', xKey3:'Key3Value' });