Caeculus
Caeculus

Reputation: 89

How Google Analytics inserts the tracking pixel?

I am working with JS and I was looking to the GA's JS codes and I noticed something.

When I upload a page, in the console I see an image request like that;

https://www.google-analytics.com/collect?v=1&_v=j82&a=174999582&t=pageview&_s=1&dl=..

This is an image as the console said. I get this, Google inserts an image with some information about user behavior and collects the data from the request for the image. But when I look the page I can not find this "pixel", how can they send the request without including it in the page?

Upvotes: 0

Views: 216

Answers (1)

Julian
Julian

Reputation: 2822

When you open the network tab in the developer tools you can see the Initiator of the request analytics.js:25. When you click on it, it will show you the code that adds a img tag with js var b=M.createElement("img");b.width=1;b.height=1;b.src=a.

The Browser loads the image even if it is not added to the DOM. That is why you can't find it there.

Upvotes: 1

Related Questions