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

489
Views
Google Tag Manager - custom javascript to extract dataLayer variable

Firstly, apologies for the lack of technical know-how...

I have a datalayer variable in google tag manager which I want to extract information from using custom javascript but I'm not the most technical.

From the picture attached, I want to extract the 'Desc' part of each line separated by comma:

VCD-95K-ZL6-36T-22F, 40% Off Menswear

How would the custom javascript for this look like so I can enter it in google tag manager?

Thank you

enter image description here

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

0

Sure, here you go:

["Name:code, Desc:whatever desc is, the first desc basically", "Name:auto, Desc:the second description"]
.map(function(obj){return obj.split(/, desc:/i).slice(-1)[0]}).join(",")

The first line is just me trying to reproduce what you have in your DLV for testing purposes. The second line is what you'd have to do to your DLV, so your actual code in your custom jsvascript variable would look similar to this:

function(){
  return {{dlv - ecommerce.purchase.actionField.coupon}}.map(function(obj){return obj.split(/, desc:/i).slice(-1)[0]}).join(",");
}

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!