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
    },
    prebidGlobal: 'pbjs',              // Optional, default: 'pbjs'
    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. A plain value only: a promise or a consent wrapper is refused. 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, and enable the [ad impression measurement](#ad-impressions) behind real-time ad revenue. Default: `false`
prebidGlobalstringoptionalName of the global Prebid.js object, if your wrapper renames it. The tag listens to its `bidWon` event to record the real winning CPM of each Prebid impression. Default: `'pbjs'`. See [Ad impressions](#ad-impressions).
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).

Ad impressions

With Google Publisher Tag on the page and monitoring.googletag set to true, the tag records every ad request and every rendered ad impression of the page:

  • its line item and creative IDs;
  • whether it was measurable (rendered in a browser able to measure it, outside an out-of-page slot, which Google Active View does not measure either) and viewable (GPT’s impressionViewable event, the MRC standard: 50% of the pixels on screen for one second);
  • for a Prebid.js impression, the real CPM of the winning bid and its currency, which the line item price bucket only approximates.

From these, Alke Analytics estimates the revenue of the page in real time. The Google Ad Manager import of the next day replaces the estimate. For Prebid.js impressions, the revenue valued at the real winning CPM is kept when it is higher than what Google Ad Manager reports, and the viewability measured in the browser is kept when Google’s files carry none. This data requires consent to TCF purpose 7 (measure advertising performance), like the creative IDs. Without monitoring.googletag, none of it is collected and the ad revenue of the page is only known after the import.

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.