Reference
JavaScript API
The widget exposes a small object on window. You never need it for ordinary use — it exists for pages that build their own UI or render buttons after load.
Widget 2.0.0
Loading
<script async src="//static.addtosite.com/widget.js"></script>
Set options before the script runs. The widget reads them once, at startup:
<script>
window.ats_config = { num_services: 5, track: false };
</script>Methods
| Signature | Behaviour |
|---|---|
addtosite.refresh() | Re-scan the document for kits. Call it after inserting buttons into the page yourself, for example in a single-page app or an infinite-scroll list. |
addtosite.share(key, { url, title }) | Trigger one service directly, without a button. Useful behind your own UI. |
addtosite.menu({ url, title }) | Open the universal menu for a given link. |
addtosite.services | The catalog the build shipped with: key, name, color and URL template for every service. |
addtosite.version | Version string of the loaded widget. |
Markup contract
A kit is any element with the ats_kit class. Its children carry ats_button_<service> classes, in the order you want them shown. An empty kit falls back to the default set.
<div class="ats_kit ats_kit_size_32"> <a class="ats_button_facebook"></a> <a class="ats_button_x"></a> <a class="ats_dd"></a> </div>
| Attribute | On | Effect |
|---|---|---|
data-url | kit | Share this URL instead of the current page |
data-title | kit | Share this title instead of the document title |
data-also | kit | Previous addresses of this page, comma separated, whose counts should be added in |
data-label | button | Show this text beside the icon |
Tracking endpoints
Served from data.addtosite.com. The widget only ever calls the first one, and never waits for the response.
| Method | Path | Purpose |
|---|---|---|
POST | /v1/share | Records one share. Sent by the widget with sendBeacon; the site domain is taken from the Origin header, never from the body. |
GET | /v1/count?url=&also= | Per-service counts for one URL. The URL is canonicalised first, so scheme, www, a trailing slash and campaign parameters do not split a page in two. `also` takes up to five previous addresses, comma separated, and folds their counts in. |
GET | /healthz | Liveness check. |