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

75
Views
Google Tag Manager - custom Templates - injectScript API never seems to run

I have been trying my hands on creating a custom template tag, like so:

Code

// Require the necessary APIs
const logToConsole = require('logToConsole');
const injectScript = require('injectScript');

// construct URL
const url = "https://www.dwin1.com/" + data.merchantId + '.js';

// If the user chose to log debug output, initialize the logging method
const log = data.debug ? logToConsole : (() => {});

log('AWIN: Loading script from ' + url);

// If the script loaded successfully, log a message and signal success
const onSuccess = () => {
  log('AWIN: Script loaded successfully.');
  data.gtmOnSuccess();
};

// If the script fails to load, log a message and signal failure
const onFailure = () => {
  log('AWIN: Script load failed.');
  data.gtmOnFailure();
};


injectScript(url, onSuccess, onFailure, url);

Permissions

URL Pattern match: https://www.dwin1.com/

Tests

but when I now try to run a test like so

const mockData = {
  merchantId: 1001,
  debug: true
};

// Call runCode to run the template's code.
runCode(mockData);

// Verify that the tag finished successfully.
assertApi('gtmOnSuccess').wasCalled();

I get this gnarly error and don't know why: enter image description here

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

0

Hey even I faced the same issue, but as I debugged it was due to AdBlocker which was blocking the script, you need to allow it and check if you have any AdBlocker installed on your machine.

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!