Uncaught SyntaxError: got ‘&’
-
I found issue Javascript error “Uncaught SyntaxError: expected expression, got ‘&’” when using with Plugin Google Analytics for WooCommerce
it renders
gtag
function with HTML encoded valuegtag("event", "page_view", {send_to: "GLA"});
I try to deep in code of plugin, I found interesting in 2 methods in file
/src/Google/GoogleSiteTag.php
at function
display_page_view_event_snippet
it pass value ofadd_inline_event_script
with string'gtag("event", "page_view", {send_to: "GLA"});'
private function display_page_view_event_snippet(): void { if ( ! is_cart() ) { $this->add_inline_event_script( 'gtag("event", "page_view", {send_to: "GLA"});' ); return; } ...
then in method
add_inline_event_script
, inline script that pass as parameter will be wrap with functionesc_js
, so quote symbol will be rendered as"
then this leads to JS error.I not sure is this can be defect or bug when use these plugin together? let me know if Developer team see this topic and anyone found out solution
My Environment
WordPress – 6.4.3
Google Listings and Ads – 2.6.2
Google Analytics for WooCommerce – 2.0.3
- The topic ‘Uncaught SyntaxError: got ‘&’’ is closed to new replies.