Walker Formulation Academy for developers API reference Error catalog OpenAPI
Sections

#The loader.js Loader

Status: Available.

Purpose: one <script> tag connects the Walker Formulation Academy visit counter, behavior tracking, and chat to a site, and controls them through visitor consent.

#Contents

  1. When to use it
  2. Access
  3. What the loader includes
  4. Manual installation
  5. Visitor consent
  6. Cookie banner integration
  7. How to verify the installation
  8. Server response and caching
  9. Notes
  10. Open questions

#When to use it

If you only need a visit counter without binding the site, use the JS tracker by token.

#Access

Authenticationthe site's public key in the k parameter (it is not a secret)
Paidno
Personal dataIP and User-Agent hashes, page, source (see Overview)
Where the key comes fromissued when the site is bound (the bind response, field public_key); equal to this site's tracker token

#What the loader includes

The loader is built in the cloud from the site's settings and connects only the enabled parts.

PartSite settingWhat it does
Trackertrackerone visit per page load (the same mechanism as in the JS tracker)
Behaviorbehaviourthe visitor behavior tracking script; starts only with consent
Chatchat and chat_channel_idthe chat bubble; enabled only if both values are set

All site settings:

FieldTypeValuesMeaning
trackerbooleantrue/falsethe visit counter; the switch also applies to the module's server beacon
behaviourbooleantrue/falsebehavior tracking
chatbooleantrue/falseon-site chat
chat_channel_idstringchannel identifierwhich channel answers on the site
consent_modestringwait | immediatewhen to start the loader parts
server_beaconstringfull | anonymous | offthe module's server beacon mode

Staff change the settings in the dashboard: "Promotion → System → Sites (module)".

#Manual installation

The public key is shown in the bind response (connector protocol); the dashboard does not currently display it (see open questions).

Step 1. Before the main tag, add the consent queue stub. It is needed so that a consent call made before the script loads is not lost.

<script>
  window.sapport = window.sapport || {
    q: [],
    consent: function (v) { this.q.push(['consent', !!v]); }
  };
</script>

Step 2. Add the loader of your site's cell (the example is for RU; for EN use https://wfacademy.org, for ID https://wfacademy.id):

<script async src="https://formula-cream.pro/api/v1/connector/loader.js?k=0123456789abcdef0123456789abcdef"></script>

Request parameters:

ParameterTypeRequiredConstraintsExample
kstringyes32 hex characters, the site's public key0123456789abcdef0123456789abcdef

Step 3. Place the tag on all pages that should be counted (usually in the shared template, in <head> before </head>).

The mode is set by the consent_mode setting.

ModeBehavior
immediatethe loader parts start right after loading
waitthe parts wait for a call to window.sapport.consent(true) or for the sapport:consent event

#Page API

// consent given
window.sapport.consent(true);

// consent revoked: stops behavior tracking
window.sapport.consent(false);

// the same via an event
window.dispatchEvent(new CustomEvent('sapport:consent', { detail: true }));
// the { granted: true } form is also accepted
window.dispatchEvent(new CustomEvent('sapport:consent', { detail: { granted: true } }));
ElementDescription
window.sapport.qthe queue of calls made before the script loads; the loader processes it in order
window.sapport.consent(bool)give or revoke consent
sapport:consent eventdetail === true or detail.granted === true means consent is given
PartWithout consent (wait mode)After consent(false)
Visit counterstarts according to the mode's rulesa hit already sent cannot be taken back
Behavior trackingdoes not startstops
Chatthe bubble loads immediately, regardless of consentn/a
Chat datathe widget does not record the first touch (first-touch) and does not pass the query string, title, and referrer into the framen/a

Wire the calls to the buttons of your consent banner:

document.querySelector('#cookie-accept').addEventListener('click', function () {
  window.sapport.consent(true);
});
document.querySelector('#cookie-reject').addEventListener('click', function () {
  window.sapport.consent(false);
});

// the saved choice on the next visit
if (localStorage.getItem('cookie-consent') === 'granted') {
  window.sapport.consent(true);
}

If your banner offers a choice by category, bind consent(true) to the "analytics" (statistics) category, not to "marketing".

#How to verify the installation

  1. Open a page of the site with developer tools, "Network" tab. There should be a loader.js?k=… request with status 200.
  2. Make sure the response is not a stub: the body must not equal /* Sapport connector: off */.
  3. In the console, run typeof window.sapport.consent; the expected result is function.
  4. Check the visit request: after the page loads, a POST /api/v1/track/visit goes out, with response 204.
  5. In the dashboard under "Promotion → System → Sites (module)", the site should be in the "bound" state, with "Visit counter" and the parts you need enabled.
  6. If both a module and a manual tag are on the page, visits will be doubled; keep one.

#Server response and caching

Method and addressGET /api/v1/connector/loader.js?k=<key>
Success200, application/javascript
Disabled or unknown key200 with the stub /* Sapport connector: off */
Cache-Controlpublic, max-age=300
HeadersAccess-Control-Allow-Origin: *, Cross-Origin-Resource-Policy: cross-origin, X-Content-Type-Options: nosniff, HSTS

If you disable the site or a part in the dashboard, mind the cache: the loader will go empty on pages within 5 minutes.

#Notes

#Open questions

  1. For the owner. Where to get the public key without a module. The public_key field is in the binding response, but the dashboard does not show it and does not issue a ready-made tag. Manual installation is therefore supported as a protocol scenario, not as a dashboard button. A decision is needed: show the key and a ready-made tag in the site card.
  2. Technical. The same key serves as the tracker token: should we warn that it is public and allows hits to be written from other people's pages (protection: limits and quota; see JS tracker).