How to find the source of this javascript file? - google-analytics

I am trying to find which file calls this google analytics js file.
The file is not in the HTML source code. It is either call by a tag management system like GTM or another JS file.
I used chrome developer tools to track it down but not real luck finding it. So far I am thinking it is in the cdn.optimizely.com
Is there something I am missing or a tool that I haven't used yet?

This looks like it's being introduced by the GTM container, which can be seen in your screenshot, with the container ID of GTM-TDDX2G. If you have access to that container, then you should also be able to see the base/pageview tag which uses the particular tracking ID on that page.

Related

How does Google Optimize AB testing work?

Specifically, how does it manage to serve different versions of the same site, with no access to the server or anything, just a script on the head?
The way all client-side testing platforms work is by applying the changes by executing JS on the top of the existing HTML of the page.
Basically, these platforms provide WYSIWYG editor that allows you to make the changes on any site. These changes can range from simple changes like color/text/layout to more complex changes where you can modify the HTML content of any element altogether.
Every change done via visual editor generates a corresponding JS code that will get executed on the fly when someone participates in one of the variants.
To summarize, the flow will be:
Inside the platform
Place the JS snippet of the platform on the site(should be inside the head tag to avoid any flickering).
Create the test and the variants in the platform using the visual editor or by writing your own code inside the code editor.
Run the test.
On the website
The user visits the site and the respective platform's JS snippet executes.
Snippet connects to the nearest CDN and brings back the test configuration along with the platform's library.
The library executes quickly and applies the changes to the respective elements by firing the JS snippet generated during the variant creation.
The library sends a hit to track the user along with variant info inside the platform reporting.
You will get the stats in real-time and will get to know which variant performed the best.

Tracking Clicks [Outbound Links] with Autotrack.js

I am trying to find a clear method of tracking clicks to external sites from a site I have built, it appears a lot of information available on this is contradictory or incomplete. I have found autotrack.js on Github which looks like a simpler method, so my question is three-fold, I'll make the question super clear so there is a super clear answer for others in the same conundrum as me.
What snippet/script is added to the HTML and where? I currently have the standard GA snippet for tracking page loads before the </body> tag.
Should I amend / edit the <a> tags to make sense of the who clicked what? I.e. name them, can this be avoided or automated, what I mean is there a script smart enough to name it the same as the destination, like reallygoodlist.com or fb.com/reallygoodlist ?
Is there any GA work required? Set up Goals etc, ideally I would be looking to avoid this - I have a lot of links.
Here is my site (if it helps):
http://www.reallygoodlist.com
1) What snippet/script is added to the HTML and where? I currently have the standard GA snippet for tracking page loads before the tag.
The installation and usage section of the autotrack documentation shows how to install autotrack, so I'll just link to it rather than repeating.
If you're just using the default GA tag, you can probably copy/paste most of the code there, changing the parts relevant to you: e.g. if you only care about outbound link tracking, then only include the outboundLinkTracker plugin.
It also looks like you're installing code via npm, so in this case you can link autotrack's source file in the node_modules directory as you've done with the Babel polyfill.
<script src="node_modules/autotrack/autotrack.js"></script>
2) Should I amend / edit the tags to make sense of the who clicked what ? i.e. name them, can this be avoided or automated, what i mean is ether a script smart enough to name it the same as the destination, like reallygoodlist.com or fb.com/reallygoodlist ?
Autotrack's outboundLinkTracker plugin automatically sets the link's URL as the event label, so you probably don't need to do anything unless that's not enough.
If you want more control than that, setting one of the common options will allow you to custom any data that is sent to GA.
3) Is there any GA work required? Set up Goals etc, ideally I would be looking to avoid this - I have a lot of links.
Not for outbound link tracking. It's just tracking the data as events, so you'll be able to find them in your event reports in GA.

Automatic checking of GTM Tags

Is there is a tool or a solution that automatically checks if the GTM (Google Tag Manager) tags are working properly on a page?
I don't need it to do anything else except retrieve the bag of tags and let me know which any URLs where there is a problem with a tag.
I can only find manual validation checking and I would need to implement a solution for a large number of tags so automation would be most helpful.
There are a few paid services that I can think of:
Observepoint
Tag Inspector
I'm sure there are others, but those are the ones I've used.
You can also use GTM's error tracking to log client-side JS error. Doesn't really check to see what tags are firing, but will let you know when your JavaScript is having problems.
Good blog post here: Using Google Tag Manager to log JavaScript errors in Google Analytics

Cross Domain iFrame auto height resizing

I've been googling and looking at various options but could not seem to be able to find a perfect solution that works in what I'm attempting...so needing some help here.
The situation/environment that I have is the following:
Parent page (which has the iframe) - is on a different domain, and the only control I have is a portion of the body tag, where it is updated via an admin console using html/WYSIWG editor. No access to head tag or even hosting jscript in their domain.
Child page (iframe) - is hosted in our domain, and we have full control.
The parent site is actually 3rd party online stores where we have products there, and we want to put in common information that we can control on our end without having to edit each individual product listing one by one.
I've tried alot of options found but it does not seem to work as either they need to include in js file or access to the head tag in the parent page.
So wondering if there are any other options that can help us on this?
I'm afraid you need access to JavaScript on both domains to do this.
Could you get the 3rd online store to host a small JS library that all their clients could then use to solve this problem? I work on a project that allows third parties to add in iFrames and produced this little project for just this reason. When any one say they want to be able have their iFrame resize to content, we point to the iFrame js file and say include this on your page.
https://github.com/davidjbradshaw/iframe-resizer
Sorry, that's not quite the answer your after, but trying asking the store to support this and they might be open to the idea, as I expect others have the same issue with their site.

Google Analytics Implementation

I'm looking at implementing Google Analytics and was wondering:
Can the tracking code be put in an external file, with the rest of my js then minified? If not, can the js be minified to one line then used on my page?
Or does the code have to go in my ? In some examples I've seen it after the body tag at the bottom of the page, why is this?
yes you can put it in your external .js file.
No It doesn't matter really where in the page you place it. Some people put it in the Head tag others in the footer. Personally I place it in the head tag that way I can add event tracking and custom dimensions though out the page as its built. But its really personal preference where you place it.

Resources