1. Documentation /
  2. Pixel Manager Pro for WooCommerce /
  3. Developers Documentation /
  4. Hooks

Hooks

Hooks give you the ability to use the plugin’s functionality in your own code.

For instance, not all themes follow WooCommerce conventions. In this case, you can use hooks like the pmw_print_product_data_layer_script_by_product hook to add the product details to the data layer.

Add product details to the data layer

↑ Back to top

This hook adds the product details to the Pixel Manager data layer. Use it in your product template file.

This architecture is useful because it allows the product details in the data layer to be added only when the product is displayed and works very well with caching plugins.

product-template.php

do_action('pmw_print_product_data_layer_script_by_product', PRODUCT_OBJECT);
product-template.php

do_action('pmw_print_product_data_layer_script_by_product_id', YOUR_PRODUCT_ID);