Script attributes
Overview
Script attributes provide the simplest way to configure the SDK using data-* attributes on the script tag.
Basic setup
<script src="https://sdk.ocmcore.com/sdk/ht-latest.js" data-tag="NjY4bL60M84D7DQ235QxNDY4MjE0NhGg" async></script>
Supported attributes
data-tag
- Type:
string - Required: Yes
- Description: Your configuration key used by auto-conf to fetch settings from Configuration Hub
data-analytics
- Type:
"1"or"0" - Default:
"0" - Description: Enable/disable analytics tracking (page views, clicks) before auto-conf loads
data-amp
- Type:
"1" - Default:
"0" - Description: Enable AMP mode for push notification flows
data-modal_url
- Type:
URL - Default:
https://cdn.ocmtag.com/c/ - Description: Remote URL where modal templates are hosted (e.g.,
https://cdn.example.com/modals/)
data-tag_url
- Type:
URL - Default:
https://cdn.ocmtag.com/c/ - Description: Remote URL where auto-conf JSON configuration is hosted (e.g.,
https://cdn.example.com/config/)
data-disable-autoconf
- Type:
"1" - Default:
"0" - Description: Disable auto-conf fetching - use only local configuration
data-no-override
- Type:
"1" - Default:
"0" - Description: Prevent remote auto-conf from overriding local settings (when “1”, local settings take priority over remote config)
data-crashlytics
- Type:
"1"or"0" - Default:
"0" - Description: Enable/disable JavaScript error reporting
data-consent
- Type:
"1"or"0" - Default:
"0" - Description: Set to “1” only after user has given consent for advanced tracking - enables persistent user ID for better analytics and user recognition (without consent, only anonymous session tracking)
data-function
- Type:
string - Default:
"Hood" - Description: Custom name for the global function used to call SDK methods like
Hood('init'),Hood('trackevent')
Protected attributes
These attributes are ignored for security reasons and must be configured via auto-conf:
data-analytics_url
URL where tracking data is sent
data-crashlytics_url
URL where JavaScript errors are reported
data-activity_url
URL where user activities are logged
data-subscription_url
URL where profile subscriptions are managed
Examples
Basic tracking
<script src="https://sdk.ocmcore.com/sdk/ht-latest.js" data-tag="NjY4bL60M84D7DQ235QxNDY4MjE0NhGg" async></script>
With analytics enabled
<script
src="https://sdk.ocmcore.com/sdk/ht-latest.js"
data-tag="NjY4bL60M84D7DQ235QxNDY4MjE0NhGg"
data-analytics="1"
async>
</script>
Custom URLs
<script
src="https://sdk.ocmcore.com/sdk/ht-latest.js"
data-tag="NjY4bL60M84D7DQ235QxNDY4MjE0NhGg"
data-modal_url="https://cdn.example.com/modals/"
data-tag_url="https://cdn.example.com/tags/"
async>
</script>
When to use
Good for:
- Simple setups
- Basic tracking
- Quick integration
- Standard configurations
Not suitable for:
- Complex modal configurations
- A/B testing setups
- Advanced targeting rules
- Custom push configurations
Limitations
- Only supports simple key/value pairs
- No complex object configurations
- Limited to basic features
- Cannot override protected URL keys