Initialization

Configure the Alke Analytics SDK with your property settings and customize behavior for your application.

Configuration Options

Each platform SDK accepts configuration parameters that control how analytics data is collected and sent.

setConfig(options)

alkeAnalytics.setConfig({
    propertyId: 'your-property-uuid',  // Required
    autoPushPageview: true,            // Default: true
    countryCode: 'FR',                 // Optional
    cookie: {
        domain: '.example.com'         // Optional
    },
    monitoring: {
        googletag: true                // Optional, default: false
    },
    requireExplicitConsent: false,     // Optional, default: false
    contentSelector: 'article.body'    // Optional
});
ParameterTypeDescription
propertyIdstringrequiredYour Alke Analytics property UUID from the dashboard
autoPushPageviewbooleanoptionalAutomatically track a pageview on initialization. Default: `true`
countryCodestringoptionalISO 3166-1 alpha-2 country code — **exactly two letters**, any other value is discarded rather than stored. It takes precedence over the geolocation the CDN would otherwise resolve, and is reported in upper case. The same value can be set later with `setDimension('countryCode', …)`, which mirrors this option. See [Content Dimensions](/content-dimensions/#available-names).
cookie.domainstringoptionalCustom cookie domain for cross-subdomain tracking
monitoring.googletagbooleanoptionalPass the current pageview ID to Google Publisher Tag via `googletag.setConfig({ targeting: { alke_id } })` so ad requests include it. Default: `false`
requireExplicitConsentbooleanoptionalEnable **no-exemption mode**: hold every report to the Alke Analytics servers until the user grants explicit consent to the Alke Tech vendor (IAB TCF vendor `1506`). The tag keeps working normally (tracking, ad targeting); only network transmission is withheld — cookie behaviour is unchanged compared to the default mode. On consent, all pending reports are flushed at once, de-duplicated per logical event (most recent version of each). That consent is the **only** thing that releases a report: a refusal, no decision, an unreachable CMP and a `gdprApplies=false` all send nothing at all, so traffic that never consents is never measured. Default: `false` (data is collected under the consent exemption). See [Consent Management](/consent/#no-exemption-mode).
contentSelectorstringoptionalCSS selector of the article body, used to count words and in-article media. Without it, both fall back to what the page's JSON-LD carries. See [Content Dimensions](/content-dimensions/#counting-words-and-media).

Asynchronous loading (command queue)

The collector script is loaded asynchronously, so window.alkeAnalytics may not exist yet when your page code runs. Use the command queue window.alkeAnalyticsCmd to defer calls until the SDK is ready — any function you push runs as soon as the SDK has initialized (and immediately once it’s already loaded):

<script async src="https://…/collector.js"></script>
<script>
  window.alkeAnalyticsCmd = window.alkeAnalyticsCmd || [];
  window.alkeAnalyticsCmd.push(function () {
    // window.alkeAnalytics is guaranteed to be available here
    window.alkeAnalytics.setConfig({ propertyId: 'your-property-uuid' });
  });
</script>

This is the supported way to guarantee ordering under async loading: push your setConfig, your video setup, and anything that reads from the SDK (e.g. getVideoAdTargeting) inside a queued callback so it never runs before the SDK is ready.

Inside a callback, a dimension declared before setConfig() is kept: setConfig() derives the automatic dimensions of the first page, but it is not a page boundary, and the automatic extraction never overwrites a value you set explicitly. See Content Dimensions.

Functions that return a value
The queue runs your callback but does not return its value to the caller. For methods whose return value you need synchronously — such as getVideoAdTargeting(playerId) when building a VAST ad tag — read them from inside a queued callback (where window.alkeAnalytics exists), not before the SDK has loaded.

Verifying Installation

Open your browser’s Developer Tools (F12) and check the Network tab for requests to ca.alketech.eu.

// Check if alkeAnalytics is available
console.log(typeof alkeAnalytics); // Should output: "object"

For mobile SDKs, enable debugMode to see detailed logs in the console.

Debug Mode
Enable debugMode during development to see detailed logs. Remember to disable it in production builds.