Furkan Gözükara
Furkan Gözükara

Reputation: 23820

Where to put Universal Analytics code - inside head before close or inside body after opening

I am migrating from Google Analytics (ga.js) to Universal Analytics (analytics.js). However there is no documentation about where to put this code.

Should I place it after <body> open, or before </head> close?

Upvotes: 1

Views: 2199

Answers (1)

Nick Blexrud
Nick Blexrud

Reputation: 9603

Place it before the closing </head> tag.

Source: Introduction to Analytics.js - Tracking Code Quick Start

To begin tracking a website using analytics.js, paste the following JavaScript snippet into your website template page so that it appears before the closing </head> tag. The UA-XXXX-Y, parameter must be replaced with the Web Property ID for the Google Web Property you wish to track.

Upvotes: 6

Related Questions