Skip to main content

Signup page

The signup zone lets a visitor without an account join a loyalty programme from a web page: email address and password, an optional 6-digit code, then the member card with links to Apple Wallet, Google Wallet and the mobile app.

This page is the technical reference. For what the signup page is and how it is used in a programme, see Channels > Signup page.

How it works​

A signup page is a normal Embed Elements page with two differences:

  1. Visitor mode. initializeSpaazaElements() is called with an auth object that has no jwt and no sessionKey property. The controller then makes no member calls and loads no member data.
  2. A signup custom zone. The host configures customZones.signup. The controller places the signup form on the page. See Custom Zones for how custom zones work.

Minimal example​

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Join ACME Rewards</title>
<style>
/* Brand colours for the form; see "Styling" below */
#signup {
--content-primary-action-background-color: #D7262E;
--content-primary-action-text-color: #FFFFFF;
}
</style>
</head>
<body>
<div id="signup"></div>

<script type="module">
import { initializeSpaazaElements } from 'https://elements-test01.spaaza.com/elem/spaaza-elements.js';

// Optional: a store code in the link (?store=1234) links the new member to that store
const store = new URLSearchParams(location.search).get('store');

await initializeSpaazaElements({
target: '#signup',
componentBaseUrl: 'https://elements-test01.spaaza.com/elem/',
config: {
origin: 'https://{API hostname}',
// No jwt and no sessionKey property: visitor mode
auth: { myPriceAppHost: '{MyPrice App hostname}', chainId: '{chain id}' }
},
pageName: 'join',
customZones: {
signup: [{
page: 'join',
index: 0,
content: {
brandname: 'ACME Rewards',
logo: '/img/acme-logo.png',
imgbase: '/img',
appstoreurl: 'https://apps.apple.com/app/{your app id}',
playstoreurl: 'https://play.google.com/store/apps/details?id={your app id}',
privacyurl: 'https://www.example.com/privacy',
verification: 'otp',
storecode: store && /^[\w-]{1,40}$/.test(store) ? store : ''
}
}]
}
});
</script>
</body>
</html>

Zone content​

All settings of the form go in customZones.signup[].content: the content of the signup entry under Custom Zones.

Set every key that carries a name, a logo, a text or a link: brandname, logo, appstoreurl, playstoreurl, privacyurl and valueline. A key that is left out falls back to a built-in value that belongs to another brand.

KeyMeaning
brandnameName of the programme. Used on the member card and the app tile.
logoURL of the programme logo, shown at the top of the member card.
imgbaseFolder that holds the four badge images, under exactly these file names: add-to-apple-wallet.svg, add-to-google-wallet.svg, app-store-badge.svg and google-play-badge.png. Use the official badge files of Apple and Google.
appstoreurl, playstoreurlLinks to the mobile app. The member card step always shows the app tile, so set both.
privacyurlLink to the privacy policy, shown on the form.
valuelineOptional line above the form. Empty hides it.
verificationotp (default): a 6-digit code by email. sms: the form also asks for a mobile number and the code is sent by SMS. off: no code step.
phonecountryWith verification: 'sms': the country preselected in the dial-code picker, as ISO code (for example GB). The customer can pick any country.
phoneflagson shows country flags in the dial-code picker. Default off.
minpasswordMinimum password length, 6 when left out. Use the same value as the brand's mobile app.
storecodeStore code the new member is linked to. Usually read from ?store= in the link, as in the example.
textsObject that replaces single texts of the form by their name. See Texts and languages.

The verification method must match the programme's settings: otp needs email verification by code, sms needs phone number verification. Ask the Spaaza team which one applies to your programme.

The steps​

StepWhat happens
JoinThe visitor enters an email address and a password (and a mobile number with sms). The account is created.
CodeOnly with otp or sms. A 6-digit code is sent; the visitor enters it. A new code can be requested after a short wait.
Member cardThe member card with barcode is shown, with a tile for the phone's wallet and a tile for the mobile app.

The new member's session is kept by the controller for the browser tab only. Reloading the page resumes the step the visitor was on, and a code that was already sent still works. Closing the tab ends it: a new tab starts at the first step. The page is a way to join, not a way to log in.

Wallet​

  • On a phone the wallet tile shows an "Add to Apple Wallet" or "Add to Google Wallet" button, depending on the device.
  • On a computer the tile shows a QR code. Scanning it with the phone adds the card there. An iPhone / Android switch is shown when the programme has a pass for both.

Wallet passes are set up per programme by Spaaza, separately for test and production. Apple Wallet needs an Apple developer account, Google Wallet a Google Wallet issuer account. A programme that already offers wallet passes in its Spaaza mobile app uses the same passes. A wallet without a pass is not shown; when there is none at all, the wallet tile is hidden.

Styling​

A visitor has no session, so the programme's theme from Spaaza Console is not loaded on a signup page. Set the brand's colours and fonts as CSS variables on the mount container (#signup in the example). The form reads the shared Embed Elements names first, so one set of variables styles the form, its buttons and the member card:

VariableUsed for
--content-primary-action-background-colorButtons, links, focus, progress
--content-primary-action-text-colorButton text, and the member card text unless --content-membercard-text-color is set
--content-secondary-action-background-colorApp tile, highlights
--content-text-colorMain text
--content-card-description-colorSecondary text, field labels
--content-card-background-colorThe form's sheet, focused fields
--content-input-background-colorFields, code boxes, tiles
--content-input-border-radiusFields and code boxes
--content-button-border-radiusButtons
--content-membercard-background-colorMember card colour
--content-membercard-text-colorMember card text
--content-error-colorError text
--secondaryFontFaceFont of the text and the buttons

On other Embed Elements pages the colours come from the theme in Spaaza Console. A signup page is the exception: it sets them in its own CSS. The defaults are listed under Styling. Everything around the form (logo, header picture, page background) is part of your own page.

Texts and languages​

Every text on the form has a name. The texts key replaces a text by its name. Texts that are not named keep their built-in wording.

texts: {
sendCode: 'Join now',
walletText: 'Keep your card on your phone.'
}

The texts that are changed most often:

NameBuilt-in text
sendCodeSend my code
consentSend me my offers and card by email.
codeTitleCheck your email
codeSentToWe sent a 6-digit code to
confirmCodeConfirm code
cardScanTextScan me at the checkout counter!
walletTextSave your card. Basic discounts at the till.
appTitle{brand} app, where {brand} is filled with brandname
appTextAll the basics, plus spend points and win prizes.

Set walletText and appText for your own programme: the built-in wording makes promises that may not apply to it. The Spaaza team can provide the full list of names.

The built-in texts are in English. Other languages are available on request.

Actions​

The form never calls the Spaaza API itself. Like every Embed Elements component it sends a content:action:start event, and the controller does the work and answers with content:action:success or content:action:error. The signup zone uses six actions:

ActionPurpose
signup-submitCreate the account
signup-code-requestSend a code by email or SMS
signup-code-verifyCheck the code the visitor entered
signup-restoreResume after a page reload
signup-wallet-passGet the Apple Wallet or Google Wallet pass
signup-forgetDrop the signup session of the tab

A host can take over an action with handler overrides. It then has to answer the action itself: with a content:action:success or content:action:error event on the element that asked (detail._targetComponent), carrying the same action and signup_info.request_id. Without an answer the form shows an error after 30 seconds. See Event System for the event model.

Security​

The visitor types a password on this page. Treat it like a login page.

  • Keep third-party scripts off the page. Tag managers, analytics and chat widgets run with the same rights as the form and can read what is typed.
  • The password is sent in one event, signup-submit, from the form to the controller. The controller stops that event at its container, so it does not bubble on to the rest of the page, and masks it in its debug log. A script that listens in the capture phase still sees the event, and so does a page that takes over signup-submit with a handler override.
  • Add a content security policy that only allows your own scripts and the API origin. Example:
<meta http-equiv="Content-Security-Policy"
content="default-src 'self';
script-src 'self' https://elements-test01.spaaza.com 'sha256-{hash of your inline script}';
style-src 'self' 'unsafe-inline';
img-src 'self' data:;
connect-src 'self' https://{API hostname};
object-src 'none'; base-uri 'none'; form-action 'none'">

Inline styles must be allowed: the components inject their own styles. If the page has an inline <script type="module">, its hash is part of the policy; editing the script changes the hash.