what does utag.DB mean? - javascript

I am stumped on figuring out what this means..
utag.DB
I am seeing it in a web page via the console. And I'm trying to figure out what it means. Any pointers are useful.

utag.db is a Tealium function for debugging. It is similar to console.log(which is non standard). It is enabled via a cookie that's set.

Caught you!!
You are curious about utag means you have implemented or trying to implement Tealium data layer in your portal.
Basically utag.db is used to debug tealium functionalities related to utag files. As rightly mentioned by #webanalyticsdood, it should be used instead of non standard console.log
That's fine but how do I and why should I use it?
Simple, set utag cookie to true in your developer console using following command
document.cookie="utagdb=true";
Let's try with following command,
utag.data
Whatever data you are passing on to tealium will be found inside utag.data. If you can't read your data based on conditional events, it won't be sent to Teamium, better go back and correct your code. Let's try another one.
utag.id
it will return id you've set for synching with tealium,
You can explore more similar stuff inside utag.js
PS: would suggest you to add tealium tag in your question.

Related

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

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.

doc.pageWindowRect and doc.media are undefined in Adobe Acrobat Javascript

I'm using the Javascript API built-in to the Adobe Acrobat products, and trying to access the doc.pageWindowRect attribute.
I originally found that doc.pageWindowRect was undefined whenever I tried to access it, and through various posts on the AdobeUsers forum, found that I needed to activate the media extension first, by running something like console.println(this.media);
Normally this prints a result like: [object DocMedia]
However, on some computers used by our client, this just prints undefined instead. It seems that having this.media remain undefined means that doc.pageWindowRect will stay undefined too.
Does anyone know how to make sure this.media is defined, and thus enable doc.pageWindowRect? Or any other way of getting hold of the doc.pageWindowRect information?
I wondered if there might be a delay in activating the media extension (a suggestion I found online), and have tried repeatedly running code to display this.media and doc.pageWindowRect using app.setInterval, but even after waiting for a couple of minutes, they are still not defined.
Any suggestions would be greatly appreciated.
It seems that having this.media remain undefined means that
doc.pageWindowRect will stay undefined too.
Does anyone know how to [...] enable doc.pageWindowRect?
pageWindowRect belongs to the multimedia.api plugin. In Acrobat 9 and possibly other versions, this plugin is not by default loaded.
From what I can find in that scenario, one method for loading the multimedia.api plugin is to actually have media in the PDF file.
Default location for this plugin is: %Program Files%\Adobe\Reader 11.0\Reader\plug_ins\Multimedia.api
This might not be the fixing answer, but I hope the suggestion gives some insight. Good luck!

How to determine the line of javascript code which changes the url?

I have an existing site with a lot of javascript included. My javascript is adding a query string parameter (using history.replaceState) but right after the adding, it gets removed. How can I find the line of javascript who is removing my query string parameter? (I've been trying to place breakpoints in the Chrome dev tools on certain method calls but no luck so far.)
There is no real network navigation happening here, all changes come from javascript and angularjs.
With given information I can only say that its probably a redirection that must be removing your query parameter. Try enabling preserve network logs and then track the network calls to see if there are any redirections happening.
Following steps solved my problem:
First I've hijacked the pushState and replaceState methods to see when they are triggered. Everywhere where expected they were triggered. No other known calls are made. The catch is in the AngularJS $location component. It checks what happens onUrlChange and removes data which is no hash and is different from the baseUrl (as far as i can understand from checking briefly)

How to run js code pulled from server side in angularjs?

I am using Laravel as my back-end and Angularjs as my front-end for my website. I need to pull some js code (advertisement purposes, like Adsense) from server side and run it in Angularjs.
I got some ideas from https://www.ng-book.com/p/Security/ . First I use $sce to make the js code trusted so that angularjs can run it,
$scope.safeJsCode = $sce.trustAsJs($scope.unsafeJsCode);
then I use ng-load to eval() the safeJsCode
<script ng-load="run()"> </script>
$scode.run() = function()
{
eval($scope.safeJsCode.toString());
};
However, I was not able to run it. Can someone give me some ideas on how to solve this predicament? Thanks!
So if I understand correctly, you think that ng-load can call your 'run' function.
Empty script tag won't fire a 'load' event, so no wonder that it is not being executed.
If you really need to dynamically load some script and execute it you don't need no script tags-just as soon as you fetch script from the server and get safeJsCode, eval it.
Now I don't expect you to heed my advice, but instead of doing eval(), you should really think about a way how you can achieve with just data. In most cases this can be solved by just having your own smart code.
There are case which comes to mind- like a dashboard with customizable widgets, where people can write 3rd party widgets. Problem is, these never catch on and they are very prone to bugs and usually are sluggish.
If you trully need dynamicity though, you could try loading those script with https://github.com/systemjs/systemjs

Calling a function in a JavaScript file with Selenium IDE

So, I'm running these Selenium IDE tests against a site I'm working on. Everything about the tests themselves is running fine, except I would like to do a bit of clean-up once I'm done. In my MVC3 Razor based site, I have a JavaScript file with a function that gets a JsonResult from a Controller of mine. That Controller handles the database clean-up that Selenium IDE otherwise couldn't handle.
However, I'm having a hard time finding any sort of documentation on how to do this. I know I can do JavaScript{ myJavascriptGoesHere } as one of the Values for a line in the test, but I can't seem to find a way to tell it to go find my clean-up function.
Is it even possible for Selenium IDE to do this sort of thing?
If it comes down to it, I can just make a separate View to handle the clean-up, but I'd really like to avoid that if possible.
Thanks!
If you want to execute your own JavaScript function that exists in your test page from Selenium IDE, you need to make sure you access it via the window object. If you look at the reference for storeEval for instance, it says:
Note that, by default, the snippet will run in the context of the
"selenium" object itself, so this will refer to the Selenium object.
Use window to refer to the window of your application, e.g.
window.document.getElementById('foo')
So if you have your own function e.g. myFunc(). You need to refer to it as window.myFunc().
This can be very handy for exercising client-side validation without actually submitting the form, e.g. if you want to test a variety of invalid and valid form field values.
If you use runScript, that should already run in the window's context.
This works for me.
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
string title = (string)js.ExecuteScript("myJavascriptGoesHere");
Make sure your javascript works first before using it here!
Actually to access your page javascript space, you need to get the real window of your page : this.browserbot.getUserWindow()
See this statement to get the jQuery entry point in your page (if it has jQuery of course ^^ )
https://stackoverflow.com/a/54887281/2143734

Categories

Resources