Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

447
Views
Google Tag Manager Variable Parse Error: Primary Expression Expected

I am setting up a GTM variable, and I thought this error only came up when you don't wrap all of the code in a function.

Here is my code:

    function VIN() {
      let vins = document.getElementsByClassName("xyzClass").innerText;
      let targetVIN;
      for (var i = 0; i < vins.length; i++) {
        if (vins[i].innerText === "VIN") {
          targetVIN = vins[i].nextSibling.innerText;
        }
      }
    return targetVIN;
    });

GTM is throwing the error in the title in reference to line 2 character 2.

I'm a noob, what am I doing wrong here? Thank you in advance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This will not work in a variable, since a custom JS variable requires an anonymous function, and yours is a named function.

It will also not work in a custom HTML tag, because GTM does not support ES6 features in custom tags and in variables (although it is partially supported in custom template, but those to do support DOM access).

If you use this in a custom tag, just replace "let" with "var".

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!