Issue with Google Tag Manager implementation. "Uncaught TypeError: Wb.set is not a function" - javascript

Recently I started having Issues with the Google Tag Manager.
I can't track it to a Tag or a Trigger (activated and deactivated individually to check).
The error started occurring this week (no updates were made to the system or template). I noticed when testing the implementation of a new Tag in GTM. That shortly worked but then this error message started showing in the console. Removing the new Tag didn't change the situation and since the code worked for a while (some 30minutes) I don't expect a direct relationship between the new tag and the error.
All I have is the console in the frontend that shows the following error message:
Uncaught TypeError: Wb.set is not a function
The error stems from this file:
https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXXX
Wb is started as a Map just a few steps earlier:
Wb=new Map(Vb.h.F);
Wb.set("style",{ya:4});
The GTM Script is copied and pasted from the GTM-Admin without any change made to it and is included in the header.php file of the Wordpress template. I tried copying it again and replacing the script that was in the header.php previously but the result was the same.
If looking at the actual error message in the console helps, the issue can be seen on the following URL:
https://www.bindella.ch
Any help in solving this or at least pointer to where to go look for errors would be very much appreciated.
Thanks

Very interesting, and yes, you're right, the error in the minified code makes no sense:
Let's try something different. First, just export your GTM container (the workspace that is synced with prod/live) as a JSON file in Admin section.
Open the file, look for something like set("style" See if you can find that Wb. Well, don't expect it to be Wb. I guess GTM minifies the code. It may be some weird chat bot, or something like that. From there, you'll be able to find the tag or variable that causes the issue.
I didn't look too deep into it, but that part of code looks sophisticated enough to be a part of the core container code. Actually, we can check it right here, on SO cuz it uses GTM too, let's do that.
Yes, SO has identical code. Looks like it's indeed core GTM. Well, there's a tiny probability that when you built the prod library last time, GTM had an issue and it deployed an artefact.
Try making a new workspace, make a nonsensical change in it and publish it to production. See if it lets you publish. Then see if that fixes the issue.
Now, if it doesn't then the next thing I'd try is trying to re-importing the exported JSON, forcing GTM compare the import to what's there and find differences.
Now if that shows no issues, then I would make a brand new container, load the config in it and try replacing the gtm loading script to see if the error still happens. It sounds like you can do that. If you can't, look a plugin like redirector to redirect the request to a different container.
Still the error with the new container? How about if you load a completely empty container? Got any errors?
There's a very slim chance that your front-end deploys one of a few vars GTM uses too, thus conflicting with your GTM. But it's very unlikely. Why would you use something like google_tag_manager or google_tag_data in the global scope...
If nothing helps and only the empty container doesn't give errors, then... well, then make a list of all tags firing along that error and start disabling them one by one. Or use breakpoints to narrow it down to the tag/library that causes it.

Related

Why does my D3 code break when I set the script type to module?

I am working on a project built with Javascrpt, jQuery, and Vite.js. My colleague built a data visualization using D3 - a US states map - that I need to implement in the project on a specific page. They built the component using test data, my job is basically to load the component onto a page passing it actual returned data from an API call.
Everything in the test project works perfectly, but when I tried to implement this code into a script file in the project - literally copying and pasting from the working version - I got an error saying certain properties could not be read. After failing to debug for sometime, I randomly tried removing type="module" from the script tag link in HTML, and boom, everything worked. Does anyone have an idea of why this would be? I cannot get this code to run when the script type is set to module, except I need the script type to be set to module since I'm importing lots of components for other aspects of the page.
With the way the CodePen is set up, I couldn't replicate the issue since the HTML and JS files are automatically linked. But if you copy this code into your editor, and then in the html, set the the JS file to a module ` You'll see the issue.
Thanks. I'm at a total loss for what to do here. I could put all the D3 code in it's own script file, but then I have no way pass it variables from other files if it's not a module.
Per the comments, the following lines in my original code were not working in strict mode:
this.uStates = uStates;
this.uStatePaths = uStatePaths;
The fix was simple, I just needed to write the following instead:
window.uStates = uStates;
window.uStatePaths = uStatePaths;

Opencart - cant change js files. adding kind of reddots at the end

firstly very sorry, I cant find out what the real problem is.
I ll try to explain.
My client given code which is developed using opencart and nitropack.
he includes common.js in header, it is basic js file with some ajax calls, UI events etc which has 1297 lines(no formating in code, lots of blank spaces, blank lines etc).
my real problem is, when I made any changes in this file,
the browser console is throwing error invalid or unexpected token.
I checked the common.js file in browser console, seeing that some kind of reddots added at last of the file. I just added a alert() at the begining of file. nothing else.
very sorry, dont know how to explain more detaily.
This is the first time I have seen this kind of issue.
when I removed the alert(), the error gone.

Wikitude SDK project derived from samples doesn't work

I've been modifying the sample projects Wikitude SDK provides, and I'm facing a problem: it seems like this code never works:
this.tracker = new AR.Tracker("/assets/magazine.wtc", {
onLoaded: this.worldLoaded
});
That is, the world never loads, so the function "worldLoaded" is never called.
I have no idea why the world doesn't load as the file is the original provided in the samples and it used to work.
The difference seems to be trivial, I only added a new member to the World variable that would define some additional parameteres.
The error I get is
Uncaught TypeError: Cannot read property 'apply' of undefined
ade.js:1AR.i.__executeFunctionByName ade.js:1AR.i.callAsync ade.js:1l
Any idea how to tackle this?
It seems as if you have the ADE activated, which is not necessary on a mobile device. In your HTML, please delete the line (your path to ade.js might differ slightly). This will make the error go away.
In addition, my suggestion is to also add an onError event to the tracker. In this case, you'll be notified when the tracker cannot be loaded (wrong location specified, invalid file etc), and you can react accordingly.

Javascript Error: Function is not Defined when called through onclick

I've been attempting to write a basic website for a school project, and have decided to create it using a hybrid of html and basic javascript. Currently, I have the following html code for part of the site:
HTML Code
With the javascript "ScriptWindow.js", called in line 6 as:
Javascript "ScriptWindow.js"
The main issue I have seems to be lines 11-15, where I attempt to call the javascript functions GetNext(), GetPrev(), etc. My Google Chrome developer tools tell me that the error on the site is "Uncaught ReferenceError: GetNext is not defined ", even though I thought I had defined it in the javascript file perfectly clear.
I've tried putting the javascript file through a bug tested, and there seems to be no error that I or it can find, which leads me to the presumption that the javascript file is not being properly called. I've tried pasting the javascript directly into the html code, but it still doesn't recognize that the functions are there.
This leads me to believe that it's some issue with how the onclick tries to find the javascript function, or that somehow I have placed the javascript in the wrong spot or perhaps it is not loading in time for the button to find it. I've tried moving the line where I reference the javascript to different places: At the end of the body section, before the body section, with the other two javascript declarations at the very beginning, but nothing seems to work.
If anyone could shed a little light on my issue, it would be wonderful. I am completely new to javascript, so I realize that there's probably a silly mistake (Or a big one) that I'm overlooking. Thanks for your time.

Socket.io failed to load websocket.js

I tried to use socket.io in an simple app.
When it is calling the following js file:
node_modules\socket.io\lib\transports\websocket.js
The following line failed to load (It didn't really fail. It actually returned some empty result and failed some later codes using protocolVersions):
var protocolVersions = require('./websocket');
I debugged a little bit and it seems that the intention of this line is to load the following js file:
node_modules\socket.io\lib\transports\websocket\index.js
However because there is also a "websocket.js" (the file being run) under the "transports" folder, the require functions always tries to load "websocket.js" instead, and return some unexpected results.
I changed the folder name to "websockets" and call "require('./websockets')" instead, and it fixed the problem. However this is a shared library I am not feeling comfortable messing up its codes.
I am trying to understand why this problem happened this way and what should be the best way to work around it. I am sure this piece of codes has been well tested before released.
You probably already noticed that I am using backslash '\' to separate the path. Yes I am running it on Windows! Will that create any difference?
Thanks!

Categories

Resources