Skip to content

start

The start method initializes Htag and begins the ad loading process. If using the adconsole connected htag, it will be called automatically on script load.

window.htag.api('1').start();
window.htag.api('1').start(options);
  • options (optional): An object with the following properties:
    • elementIds (array, optional): An array of element IDs to initialize. If not provided, all defined placements will be initialized.

    • urlNavigationSchema (string, optional): Specifies how URL changes are detected for single-page applications. Valid values are:

      • 'url' (default): Tracks URL changes excluding hash
      • 'hash': Tracks URL changes including hash

      Use 'hash' for applications that navigate between pages using URL hash fragments (e.g., #/page1, #/page2).

Returns the Htag API object, allowing for method chaining.

// Start with all defined placements
window.htag.api('1').start();
// Start only specific placements
window.htag.api('1').start({
elementIds: ['header-ad', 'sidebar-ad', 'footer-ad']
});
// For single-page applications using hash routing
window.htag.api('1').start({
urlNavigationSchema: 'hash'
});
// Start specific placements with hash navigation
window.htag.api('1').start({
elementIds: ['main-ad', 'secondary-ad'],
urlNavigationSchema: 'hash'
});