I am trying to track, via Google Analytics, when a button gets clicked on my site. I inserted the Google Tag Manager startup scripts into the html headers as well as the gtag_report_conversion script. Both references show up when I examine the web console in the browser.
I inserted a call to gtag_report_conversion in the onclick event using the Wix code manager. When I did this I get a red dot by the code that says gtag_report_conversion is not defined.
Hi,
To embed scripts to the site header, you should use the Track & Analyze feature . For more questions about this feature, please contact Wix Support team as they know best about this product.
Thank you Tal. I did use the Track and Analyze feature. That’s what embedded the Google code in my section. I also included the gtag_report_conversion script per Google’s instructions. I have verified using the web console that the script is in the page. The problem I’m having is referencing the script from a button’s onClick event.
The code written in the Wix Code editor is in a different scope than the code embedded using the Track & Analyze feature. Therefore, I’m afraid that there’s no option to run a script which was added to the track & analyze from the Wix Code editor (onClick event, in this case).