Manual initialization

Advanced configuration using Hood('init', tag, config) for complex setups.
developer

Overview

Manual initialization gives you full control over SDK configuration using Hood('init', tag, config) with complex object configurations.

Basic setup

<script>
  window.HoodEngage = window.HoodEngage || [];
  function Hood() { HoodEngage.push(arguments); }
  
  Hood('init', 'NjY4bL60M84D7DQ235QxNDY4MjE0NhGg', {
    // Your configuration here
  });
</script>
<script src="https://sdk.ocmcore.com/sdk/ht-latest.js"></script>

Configuration options

OptionTypeRequiredDefaultDescription
analyticsbooleanNofalseEnable/disable analytics tracking (page views, clicks)
crashlyticsbooleanNofalseEnable/disable JavaScript error reporting
consentobjectNo{ enabled: false }Consent settings for GDPR compliance
push_configobjectNo{}Push notification configuration (VAPID keys, SW settings)
modals_configobjectNo{}Modal configurations (templates, triggers, filters, A/B tests)
tag_configobjectNo{}Custom tag configurations for event tracking
modal_urlstringNohttps://cdn.ocmtag.com/c/Base URL for modal templates
tag_urlstringNohttps://cdn.ocmtag.com/c/Base URL for auto-conf JSON

Quick example

Basic manual initialization with core settings:

Hood('init', 'TAG_ID', {
  analytics: true,           // Enable analytics
  crashlytics: true,         // Enable error reporting
  consent: { enabled: true } // Consent settings
});

More examples

For comprehensive examples including push notifications, modals, A/B testing, and advanced configurations, see Manual configuration examples.

Advanced configuration options

Guaranteed execution with HoodOnLoad

If you need to ensure your configuration is applied after the script loads, use the HoodOnLoad function:

<script>  
  function HoodOnLoad() {
    Hood('init', 'TAG_ID', {
      analytics: true,
      modals_config: { /* your config */ }
    });
  }
</script>
<script onload="HoodOnLoad()" data-disable-autoconf="1" src="https://sdk.ocmcore.com/sdk/ht-latest.js"></script>

Alternative: Direct execution after load

For maximum control, you can also execute configuration directly after the script loads:

<script src="https://sdk.ocmcore.com/sdk/ht-latest.js"></script>
<script>
  // Configuration executes after SDK is fully loaded
  Hood('init', 'TAG_ID', {
    analytics: true,
    modals_config: { /* your config */ }
  });
</script>

Why queue before script load?

The SDK uses a queue system (HoodEngage) to collect calls before the script loads. If the script loads before your configuration calls, it might:

  • Execute with default settings
  • Override your queued configuration
  • Miss your custom settings entirely

The queue ensures your configuration is applied regardless of load timing.

When to use

✅ Good for❌ Not suitable for
Complex modal setupsSimple setups
A/B testing configurationsQuick integration
Advanced targeting rulesBasic tracking only
Custom push configurationsStandard configurations
Dynamic configurationsNon-technical teams
Full control over featuresLimited development resources
Custom event trackingStatic websites
Multi-environment deploymentsSingle-page applications (basic)

Best practices

Best practices

Auto-conf behavior: When using Hood('init', tag, config) with config object, auto-conf is automatically disabled. Only use data-disable-autoconf="1" if you’re using Hood('init', tag) without config object but want to prevent auto-conf.

Queue calls: Always queue Hood() calls before script loads to prevent race conditions where the script might load and execute before your configuration is set.

Validate config: Test configurations in development first

Use templates: Store complex configs in variables for reusability