Skip to content

RawJS

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.

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.

RawJS scripts are executed at the following times:

  1. When Htag is initialized (all scripts)
  2. When ads are refreshed (only scripts with the run once flag set to false)

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.

  • addRawJs: Add custom JavaScript code to be executed by Htag
  • saveEffect: Register cleanup functions for side effects