The Spaaza Environment Element provides the context and user details to other Spaaza Elements included on a page. Every functional Element needs to be included within the Spaaza Environment tag in HTML.
To include the Environment Element on a webpage do the following:
- Add the following script tag at the top of the page
<script type="module" src="https://elements.spaaza.com/elem/spaaza-environment.js"></script>
- Add the Environment tag to the contents of the page (below the script tag). Add any other Elements you want to inlude on the page within the Environment tag:
<spaaza-environment config="config_goes_here"> <spaaza-member-card></spaaza-member-card> <!-- other Spaaza Elements and HTML goes here --> </spaaza-environment>
The Environment Element has a single
config property, a stringified JSON object with the following fields:
|origin (mandatory)||The Spaaza API used - apistage0 for staging, api0 for production.|
|auth (mandatory)||A stringified JSON object with details used to authenticate the user. The JSON passed will depend on the authentication method used. Examples are shared below.|
auth fields depend on the authentication method used.
|sessionKey (mandatory)||The session key of the user from the app|
|sessionUserHash (mandatory)||The hashed session string for the user.|
|externalIDHash||A secondary hashed string used for authenticating Shopify users.|
|sessionAuthPointID||The id of the user in the app.|
|userID||The id of the user in Spaaza.|
|myPriceAppHost (mandatory)||The hostname of the client in Spaaza.|
Below are two Environment Element HTML Tag examples using different authentication parameters and APIs.