Google Analytics - track traffic only in the site folder

I want to track traffic for mysite.com/current-campaign/ and carelessly treat traffic on mysite.com in general.

Is it possible to place the GA tracking code in the files inside the /current-campaign/ folder, or should it be in the root directory of the server to track work?

+4
source share
4 answers

GA will only track the pages on which you put the tracking code, regardless of where the page is located (unless you start messing with things like settings or domain filters, etc.).

So, IOW, yes, that's fine. If you do not have a tracking code at mysite.com/somePage.html, it will not track this page (although it may appear as a URL in some reports, for example, link to a URL or exit link or something else , like on any other page, do not track)

+5
source

In Google Analytics, you can add a filter to your profile and filter everything except the selected directories. Go to Google Analytics Settings> Profile Settings and find the "Add Filter" link.

+4
source

In addition to the Crayon answer, you can restrict tracking in a subdirectory using the _setCookiePath() function in your tracking function. See analytics documentation in one subdirectory (note that binding bindings are not allowed for the correct header, at least for me).

This is recommended in the documentation for use when you want to track a subdirectory and avoid collisions with Google Analytics trackers that might be used in other subdirectories.

+1
source

I work in a department at a large university.
The departmentโ€™s webpage is at www.some-uni.com/department-name/ .
I have only FTP access to the subfolder /department-name/ and nothing else on the site.

It was pretty easy to get Google Analytics to track traffic inside the /department-name/ subfolder, ignoring the rest of the site. All I did was create a profile in GA by setting the default URL at www.some-uni.com/department-name/ . Then I pasted the tracking code onto the pages I wanted to track.

It took about eight hours for something to appear in GA, but after that everything worked out simply.

0
source

Source: https://habr.com/ru/post/1347751/


All Articles