0

I'm trying to have a custom variable in google tag manager that identifies if a page is a product page, for that i want to use Woocommerce is_product() function and pass it to GTM/GA as a custom dimension.

I already tried the solution seen here : How can I call PHP functions by JavaScript? like so:

function() {
    return <?php is_product(); ?>
}

But with no success since it always return "Undefined".

I'm a little inexperienced in javascript and php so I'm afraid that I'm missing something that is not calling properly is_product() or is_product() not returning what its supposed to return.

Thanks for the help in advance.

0 Answers0