Scope - in click event, calling function defined in HEAD

I’m trying to set up conversion tracking with Google. I used this article to add code to the HEAD tag as required to Google: Improving Conversion Tracking with Google Analytics | Help Center | Wix.com

Now, in a button click event handler, I need to call a function defined in that HEAD tag. But it is out of scope and the function call fails on click. Anyone know how to reference a function defined in the HEAD tag from a button click event handler, defined through the WIX backend UI?

Thanks!

Hello Caleb,

Unfortunately it is not possible to access header code using Wix Code.

So I guess the only way for now is to redirect the user to another like “Thank you” page and in that page track that using the Global Tag thing from Google.
https://support.wix.com/en/article/tracking-contact-form-submissions-with-a-conversion-tag

Otherwise the only solution would maybe to insert a html page into a HTML Component with all required stuff inside and a function that will be executed when that button is clicked using the .postMessage method on the HTML Component?

Wow, that’s… A good argument for getting off Wix, I guess.

@calebc Well I would not agree on that but if accessing the header is crucial you might want to rethink the platform. I still believe you will see that you will massive amount of hours working with Wix and sometimes you gotta let go of some features. Also remember that Wix Code is still a Beta Product and not released as a production environment.

@andreas-kviby The “feature” you are talking about “letting go” is conversion tracking, a fairly basic and important feature for an eCommerce oriented website.