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

The site script

Install the first-party script, report consent and leads with hms(), and see exactly what it sends, what it keeps in the browser and what it never reads.

The site script is one small asynchronous file with no dependencies. It reports page views and the first touch of a form, and it gives your pages a function, hms(), for reporting consent and leads. It sets no cookie and reads nothing about the device.

Install

Open Funnels, the tab Websites and forms, and press Install and test on your site. On the page that opens, Copy the snippet gives you two lines with your own key filled in. Paste them before </head> on every page:

<script>window.hms=window.hms||function(){(hms.q=hms.q||[]).push(arguments)};</script>
<script async src="https://heymysocial.com/sdk/v1.js?k=hms_pk_…" data-consent="required"></script>

The first line is a stub: calls to hms() made before the script has loaded are queued and replayed in order. The second line loads the script for your site. data-consent repeats the site's consent mode.

An assistant gets the same snippet from manage_tracking_sites with the action create.

The script is cached for five minutes, so a changed setting reaches your visitors within that time. For an unknown or paused key the address answers 404 with a stub that keeps hms() working and sends nothing.

What it sends by itself

Event When Properties
page_view Once, when the script loads path and referrer_host (the host only)
form_started Once per page load, the first time focus enters a field that belongs to a form path

Where consent allows it, every event also carries the session key and whichever of these parameters are in the address bar: utm_source, utm_medium, utm_campaign, utm_content, utm_term, hms_ref, fbclid, gclid. Each value is cut at 150 characters. They travel in the request body.

The script sends a page view only when it loads. On a site that changes pages without loading them, call hms('page') after each change.

Functions

Call What it does
hms('consent', 'granted') Records that the visitor agreed. Events that were waiting are sent
hms('consent', 'denied') Records that the visitor refused. The session key is removed and waiting events are dropped. Any value other than 'granted' counts as denied
hms('lead', {…}) Sends a lead
hms('page') Sends a page view for the current path

Send a lead

Call hms('lead', …) when your form is submitted:

document.querySelector('#contact-form').addEventListener('submit', function (event) {
  var form = event.target;
  hms('lead', {
    email: form.elements.email.value,
    name: form.elements.name.value,
    phone: form.elements.phone.value,
    company: form.elements.company.value,
    fields: { message: form.elements.message.value }
  });
});
Field What it is
email, name, phone, company The contact. At least a name, an email address or a phone number is needed, and an email address must be valid. A lead without any of them is not created
fields The form's other answers as an object of plain values: up to 40 answers. An answer longer than 2,000 characters is cut
external_id Your own id for the lead, if the form has one. The same id is the same lead, so sending it twice creates one

The details are sent in the body of a POST request, never in an address. The request is made with sendBeacon, or fetch with keepalive where that is missing, so the form can go on to its own destination.

A lead the visitor submitted is always sent. Where consent does not allow tracking, it carries no session and no campaign parameters, so it stays unattributed. The browser is never told what was created: the answer is only a count.

A browser can report a lead, nothing more

The collection address accepts page_view, form_started and lead_created and ignores every other type. A qualification, a sale or a refund has to come from your server, through the API or the signed webhook.

What it keeps in the browser

One value: hms_sid in localStorage, a random key of 32 hexadecimal characters made with crypto.getRandomValues. It is written only when consent allows it, and hms('consent', 'denied') removes it. Where localStorage is not available the key lives for that page only.

The script sets no cookie, loads nothing else, and never reads the user agent, the screen, fonts, canvas or any other trait of the device.

What a request looks like

The script posts to the collection address of your site, https://heymysocial.com/c/ followed by the public key. This is a page view with consent, after a click on a tracked link:

{
  "events": [
    {
      "event_id": "3f9c1e0a7b2d4c5e6f708192",
      "schema_version": 1,
      "type": "page_view",
      "occurred_at": "2026-04-12T07:30:00.000Z",
      "consent_state": "granted",
      "properties": {
        "path": "/offer",
        "referrer_host": "www.instagram.com",
        "utm_source": "instagram",
        "utm_medium": "social",
        "hms_ref": "01jc3v9k2q7x8y5z4w6t0r1s2p.9f2c4e6a8b0d1f3a"
      },
      "session_id": "5d2a9c4e7f1b3a6d8e0c2f4a6b8d0e1f"
    }
  ]
}

The server does not take the browser's word for more than it must:

  • The request's Origin has to be one of the site's allowed origins. Any other origin gets 403 with the code access_denied, and only allowed origins get a CORS answer.
  • A time that lies in the future, or more than a day back, is replaced by the time of arrival.
  • The source is always recorded as sdk, whatever the request says.
  • A request holds at most 20 events and 32 KB.
  • The answer is 202 with {"accepted": 1}: the number of events taken, nothing else.

Test the installation

Open any page of your site with the test parameter:

https://www.example.com/?hms_test=1

Instead of the normal page view the script sends one marked as a test. It appears on the site's page under 3. Check that it works as "Test: created no lead", and on the Websites and forms tab the site changes from Not tested yet to Installation tested. A test event creates nothing and is not counted as usage. It is sent whatever the consent state is, and it carries a session key only where consent allows one.

When nothing arrives

What you see What to do
The script address answers 404 The key in the snippet is wrong, or the site is paused. Copy the snippet again, or set the site's status back to receiving
The browser's network panel shows 403 from /c/… The page's origin is not in Allowed origins. Add it exactly as the browser shows it, for example with www. or for a staging address
Nothing is sent at all on a site that waits for consent Your banner never calls hms('consent', 'granted'). Until it does, events wait in memory and are lost when the page is left
Leads arrive but show "No consent" The lead was sent before consent was granted. That is the intended result
The page has a content security policy Allow https://heymysocial.com for scripts and for connections