RawJS
Overview
Section titled “Overview”The RawJS feature allows you to execute custom JavaScript code at specific points in the ad loading lifecycle. This is useful for implementing custom logic, integrating with third-party services, or adding compatibility layers for legacy code.
How It Works
Section titled “How It Works”RawJS scripts are JavaScript code snippets that are executed by Htag. You can configure these scripts in the Adconsole interface or add them programmatically through the API.
Execution Timing
Section titled “Execution Timing”RawJS scripts are executed at the following times:
- When Htag is initialized (all scripts)
- When ads are refreshed (only scripts with the run once flag set to false)
Cleanup
Section titled “Cleanup”When a RawJS script is executed, it may create side effects like global variables or event listeners. You can use the Effects API with appropriate tags to clean up these side effects.
Related Methods
Section titled “Related Methods”- addRawJs: Add custom JavaScript code to be executed by Htag
- saveEffect: Register cleanup functions for side effects