#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
- When to use it
- Access
- What the loader includes
- Manual installation
- Visitor consent
- Cookie banner integration
- How to verify the installation
- Server response and caching
- Notes
- Open questions
#When to use it
- The site is bound to Walker Formulation Academy (by a module or a binding code), and you need chat, a counter, and behavior tracking without a server-side part.
- The module for your CMS (Bitrix, WordPress) installs the loader itself; you do not need to add the tag by hand.
If you only need a visit counter without binding the site, use the JS tracker by token.
#Access
| Authentication | the site's public key in the k parameter (it is not a secret) |
| Paid | no |
| Personal data | IP and User-Agent hashes, page, source (see Overview) |
| Where the key comes from | issued 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.
| Part | Site setting | What it does |
|---|---|---|
| Tracker | tracker | one visit per page load (the same mechanism as in the JS tracker) |
| Behavior | behaviour | the visitor behavior tracking script; starts only with consent |
| Chat | chat and chat_channel_id | the chat bubble; enabled only if both values are set |
All site settings:
| Field | Type | Values | Meaning |
|---|---|---|---|
tracker | boolean | true/false | the visit counter; the switch also applies to the module's server beacon |
behaviour | boolean | true/false | behavior tracking |
chat | boolean | true/false | on-site chat |
chat_channel_id | string | channel identifier | which channel answers on the site |
consent_mode | string | wait | immediate | when to start the loader parts |
server_beacon | string | full | anonymous | off | the 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:
| Parameter | Type | Required | Constraints | Example |
|---|---|---|---|---|
k | string | yes | 32 hex characters, the site's public key | 0123456789abcdef0123456789abcdef |
Step 3. Place the tag on all pages that should be counted (usually in the shared template, in <head> before </head>).
#Visitor consent
The mode is set by the consent_mode setting.
| Mode | Behavior |
|---|---|
immediate | the loader parts start right after loading |
wait | the 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 } }));
| Element | Description |
|---|---|
window.sapport.q | the queue of calls made before the script loads; the loader processes it in order |
window.sapport.consent(bool) | give or revoke consent |
sapport:consent event | detail === true or detail.granted === true means consent is given |
#What exactly depends on consent
| Part | Without consent (wait mode) | After consent(false) |
|---|---|---|
| Visit counter | starts according to the mode's rules | a hit already sent cannot be taken back |
| Behavior tracking | does not start | stops |
| Chat | the bubble loads immediately, regardless of consent | n/a |
| Chat data | the widget does not record the first touch (first-touch) and does not pass the query string, title, and referrer into the frame | n/a |
#Cookie banner integration
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
- Open a page of the site with developer tools, "Network" tab. There should be a
loader.js?k=…request with status200. - Make sure the response is not a stub: the body must not equal
/* Sapport connector: off */. - In the console, run
typeof window.sapport.consent; the expected result isfunction. - Check the visit request: after the page loads, a
POST /api/v1/track/visitgoes out, with response204. - 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.
- If both a module and a manual tag are on the page, visits will be doubled; keep one.
#Server response and caching
| Method and address | GET /api/v1/connector/loader.js?k=<key> |
| Success | 200, application/javascript |
| Disabled or unknown key | 200 with the stub /* Sapport connector: off */ |
Cache-Control | public, max-age=300 |
| Headers | Access-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
- Connecting it twice is safe: the loader guards against a double start (the
__sapportConnectorflag). - For a
Content-Security-Policy, allow scripts and connections to your cell's domain. - The loader's counter does not support SPA navigation: it counts the page load, not an address change through the History API (behavior tracking does watch
history.pushState).
#Open questions
- For the owner. Where to get the public key without a module. The
public_keyfield 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. - 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).