Skip to content
Denne side findes på dansk. Læs på dansk
HeyMySocial

Consent modes

How the site script behaves before, with and without a visitor's consent in each of the two modes, and what consent_state means on events you send yourself.

Every tracking site has a consent mode. It decides what the site script may store and send before your cookie banner has reported the visitor's choice. HeyMySocial does not show a banner and does not decide which mode the law asks of you: your banner asks, and tells the script the answer.

The two modes

The mode is chosen when the site is added and can be changed under Settings on the site's page. In the app the two are called Wait for consent and Run until consent is denied.

required (the default) optional
Before the visitor has chosen Nothing is stored in the browser. Page views and form starts wait in the page's memory and are lost if the page is left The session key is stored and events are sent from the first page view
After hms('consent', 'granted') The session key is stored, the waiting events are sent with the time they happened, and later events are sent as they happen Events carry the state granted. Only now is a provider click id kept, as a hash
After hms('consent', 'denied') The waiting events are dropped. No page view or form start is sent The session key is removed. Page views and form starts are still sent, without a session key and without campaign parameters, so they are counted as events and tied to no visit
A lead sent with hms('lead', …) Always sent. Unless consent was granted it carries no session and is recorded as "No consent" Always sent. After a refusal it carries no session and is recorded as "No consent"

Optional is not a way around the question

Use optional only where the law lets you measure without asking first. In required mode a site that never reports consent sends no visits at all.

Tell the script what the visitor chose

Your banner calls one of these:

hms('consent', 'granted');
hms('consent', 'denied');

The script does not remember the answer from one page to the next. Your banner does, so have it call hms('consent', …) on every page as soon as it knows the choice, and again when the visitor changes their mind:

<script>
  // Call this from your banner on every page load, and whenever the choice changes.
  function reportConsentToHeyMySocial(allowed) {
    hms('consent', allowed ? 'granted' : 'denied');
  }
</script>

The call can be made before the script has loaded. The stub in the snippet queues it.

Make one page stricter

The script tag carries the mode as data-consent. Setting it to required on a page makes that page wait for consent even when the site's mode is optional:

<script async src="https://heymysocial.com/sdk/v1.js?k=hms_pk_…" data-consent="required"></script>

It works one way only. A site whose mode is required cannot be loosened from the page, whatever the attribute says.

What consent_state means on an event

Every event carries a consent_state. The script sets it; your server sets it on events it sends through the API or the webhook.

Value Meaning
granted The visitor agreed to tracking
denied The visitor refused
unknown Nobody has asked, or the answer is not known. The default when the field is left out
not_applicable No consent question applies: a phone call, a record from a CRM, a row in a file

For visit events (page_view, form_started) the state decides whether a session and its touchpoints are kept:

Sent through A session is kept when
The site script or a site's webhook The state is granted, or the site's mode is optional and the state is not denied
The API The state is granted or not_applicable

In every case the event also has to carry a session_id. Without one, the event is stored and tied to no visit.

A provider click id (fbclid, gclid) is kept only when the state is granted, and only as a SHA-256 hash together with its type. The raw value never reaches the event log.

A lead is never thrown away for lack of consent: the person asked to be contacted. What changes is what the lead may be tied to.

  • A lead whose state is denied is not tied to a session, a click reference or a tracked link. Its attribution outcome is no_consent.
  • On a site in required mode, a lead sent by the script before consent was granted is recorded as denied, for the same result.
  • A touchpoint that was recorded with the state denied is never used for attribution.

In Analytics, "No consent" is a row of its own beside "Direct" and "Unknown". It is not spread over the campaigns. See attribution.

Tracking consent is about storing a key in the visitor's browser. Permission to contact a person is recorded separately, on the contact.

  • A hosted landing page stores nothing on the visitor's device, so its leads arrive with not_applicable. Its checkbox is consent to be contacted, and the lead is not sent without it.
  • From your server, properties.contact_consent (true or false) on a lead_created event records the same thing, and properties.contact_consent_source says where it was given.

Change the mode

Open Funnels, Websites and forms, press Install and test on the site, and choose under Consent in Settings. Press Save settings. The script is cached for five minutes, so the change reaches visitors within that time. If your pages carry data-consent="required" from an earlier snippet, they stay strict until you paste the new one.

An assistant can change it with manage_tracking_sites: action update, consent_mode set to required or optional.