Skip to content
JavaScript API

One script, a few methods

There are no packages to install. The script puts one object, Conseto, on the page. This page lists what is on it, what init accepts and what is measured without any code.

What is on Conseto

These are all the methods of the global object. Version 2.0.0 is the one that runs on your site: type Conseto.version in the browser console to see it.

Conseto.init()
Starts the script and returns a promise. Call it once. The promise rejects if there is no clientId.
Conseto.track()
Sends a custom event: a name and an optional object of details.
Conseto.updateConsent()
Records a consent decision for the categories you pass (the missing ones count as refused), keeps it in the browser and tells Google Consent Mode.
Conseto.getConsent()
Returns the saved decision, or null if there is none.
Conseto.clearConsent()
Removes the saved decision. The banner asks again on the next page load.
Conseto.showBanner()
Shows the banner now. Does nothing if one is already open.
Conseto.hideBanner()
Closes the banner.
Conseto.openCookieSettings()
Opens the settings view of the banner, for a Cookie settings link.
Conseto.version
The version of the script that is running.
Conseto.instance
The analytics core after init, or null before it. This is where destroy() is.
JavaScript
Conseto.version; // "2.0.0": which build runs on this site

The options of init

Only clientId is required. What you leave out is taken from the project settings in the app, and what those leave out has a default.

HTML
<script src="https://www.conseto.io/dist/conseto.min.js"></script>
<script>
  Conseto.init({
    clientId: 'conseto_xxx_xxx',
    language: 'sk',
    theme: 'auto',
    accentColor: '#3B82F6',
    cookiePolicyUrl: '/cookies',
    privacyPolicyUrl: '/privacy'
  });
</script>
clientId
Your project ID. Required.
language
The language of the banner as a two-letter code. Without it: the project's setting, then the visitor's browser.
theme
light, dark or auto.
layout
Ignored. The banner is always a window in the middle of the page, which won the test in August 2026.
accentColor
The colour of the accept button, as a hex value.
autoConsent
Set to false and init shows no banner. You then call showBanner() yourself. Until a visitor who must opt in has decided, no events are sent.
cookiePolicyUrl
Where the cookie policy link of the banner goes. Default /cookie-policy.
privacyPolicyUrl
Where the privacy policy link goes. Default /privacy.
showRejectOnFirstView
Ignored. Reject all is always on the first screen of the banner.
reopenButtonPosition
bottom-right (the default) or bottom-left.
onConsent
A function called with the decision whenever the visitor decides.
categories
Your own list of cookie categories and the cookies in them, for the settings view. An advanced option.
ga4
A GA4 measurement ID. Without it the one saved for the project is used.
gtm
A Google Tag Manager container ID. Conseto loads the container for you.
metaPixelId
A Meta Pixel ID. The pixel loads only after marketing consent.
proxyUrl
The base address of the script's calls, for sending them through your own domain. See Public endpoints.
urlPassthrough
Google Consent Mode URL passthrough. Default false.
trackScrollDepth
Scroll milestones. Default true.
trackFileDownloads
File downloads. Default true.
trackOutboundLinks
Clicks on links to other sites. Default true.
trackFormSubmissions
Form submissions. Default true.
autoTrackEcommerce
Pick up e-commerce events from Shopify, the data layer and your own markup. Default false.
debug
Writes what the script does to the browser console. Default false.

What is measured without code

Once the script runs, these events are sent by themselves, as long as the visitor's consent regime allows it. The four switches above turn off the ones that have one.

page_view
Each page the visitor sees, including route changes through the browser history API and the back button.
page_exit
When the visitor leaves the page or hides the tab: the time on the page, and how far they scrolled.
click
Clicks on submit buttons, links to other addresses, phone and e-mail links, and anything marked with data-track, data-conseto-track, data-cta or a cta or btn class. The event takes the name from data-track, or is called click.
scroll_milestone
25, 50, 75, 90 and 100 percent of the page.
file_download
A click on a link to a file such as pdf, zip, doc, xls, csv, mp3 or mp4.
outbound_click
A click on a link to another site. E-mail and phone links are not counted here.
form_submit
A form being submitted: its id, name, path, method and number of fields, never what was typed.

Your own events

Call track with a name and, if you like, an object of details. The name keeps letters, digits, underscore, hyphen and dot, and is cut at 100 characters; anything else becomes an underscore.

JavaScript
Conseto.track('newsletter_signup', { location: 'footer' });

You can also mark an element instead of writing code. data-track gives the click event its name, data-location, data-value and data-category add details.

HTML
<a href="/pricing" data-track="pricing_click" data-location="header">
  Pricing
</a>
  • An event whose name starts with conversion_ counts as a goal. See Goals.
  • Events wait in a queue that holds 500 and are sent in batches. A visitor who must opt in has the events held in memory until the decision.

E-commerce events

Switch on autoTrackEcommerce and the script picks up view_item, add_to_cart, remove_from_cart, begin_checkout and purchase from three places: the Shopify cart, Google's data layer, and elements marked with data-conseto-ecommerce.

HTML
<script>
  Conseto.init({ clientId: 'conseto_xxx_xxx', autoTrackEcommerce: true });
</script>

<button data-conseto-ecommerce="add_to_cart" data-product="Widget" data-price="29.99">
  Add to cart
</button>

Identity for logged-in users

Optional, for developers with a login. These methods are on the object that init resolves to, so the script has to be a module script that waits for it.

HTML
<script type="module">
  const conseto = await Conseto.init({ clientId: 'conseto_xxx_xxx' });

  conseto.setUserId('user_42');                    // opaque ID, never an e-mail
  await conseto.setUserEmail('jana@example.com');  // hashed in the browser
  conseto.setUserProperty('plan', 'business');

  conseto.clearUser(); // on logout
</script>
conseto.setUserId()
Sends your opaque ID as it is. It must not be an e-mail address or anything else that names a person.
conseto.setUserEmail()
Trims and lower-cases the address and hashes it with SHA-256 in the browser. The address itself never leaves it. Returns a promise.
conseto.clearUser()
Forgets the ID and the e-mail hash. Call it on logout.
conseto.setUserProperty()
Attaches one sticky property: a key up to 24 characters, a value up to 36, at most 25 keys.
conseto.setUserProperties()
The same, for an object of properties at once.
conseto.clearUserProperties()
Forgets all the properties.

Taking it down

Before you initialise again, or when a single-page app unmounts, remove the script's listeners and its patch of the history API.

JavaScript
Conseto.instance?.destroy(); // removes its listeners, before a re-init or an unmount

Coming later

There are no published server-side libraries yet. From a server, use the public endpoints.

  • Node.js SDK
  • Python SDK
  • PHP SDK

Read next

Checked against the code on 1 October 2026.

Missing something?

This is everything we document today, and each page says only what the script and the gateway do now. If you need a guide that is not here, tell us what you want to achieve.

Write to us