Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Tag Manager Parse Error. Primary Expression

I am trying to save this Custom Javascript Variable within Google Tag Manager and return this error each time:

Error at line 2, character 4: Parse error. primary expression expected

var prodID = function pID() {
return document.querySelector(".no-display > input[name=product]").value;
}();

Can someone help me? I believe I have a primary expression.

like image 762
Spencer Gallardo Avatar asked Oct 29 '25 08:10

Spencer Gallardo


1 Answers

To fix the issue in Google tag manger, I simple re wrote the code to be :

function() {
  return document.querySelector(".no-display > input[name=product]").value;
}
like image 149
Spencer Gallardo Avatar answered Oct 30 '25 23:10

Spencer Gallardo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!