start
Overview
Section titled “Overview”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.
Syntax
Section titled “Syntax”window.htag.api('1').start();window.htag.api('1').start(options);Parameters
Section titled “Parameters”- 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).
-
Return Value
Section titled “Return Value”Returns the Htag API object, allowing for method chaining.
Examples
Section titled “Examples”Basic initialization
Section titled “Basic initialization”// Start with all defined placementswindow.htag.api('1').start();Start specific placements
Section titled “Start specific placements”// Start only specific placementswindow.htag.api('1').start({ elementIds: ['header-ad', 'sidebar-ad', 'footer-ad']});Hash-based navigation
Section titled “Hash-based navigation”// For single-page applications using hash routingwindow.htag.api('1').start({ urlNavigationSchema: 'hash'});Combined options
Section titled “Combined options”// Start specific placements with hash navigationwindow.htag.api('1').start({ elementIds: ['main-ad', 'secondary-ad'], urlNavigationSchema: 'hash'});