How do I track forms that submit to themselves? (posted: 8/8/2008)
Google Analytics uses the URL’s that are displayed in the browser’s address bar to create different pages in the reports. This causes a problem when a page posts back or submits to itself, as the URL does not change in these instances. Therefore, Google Analytics will not differentiate between the two pages. We can get around this problem by uniquely defining the urchinTracker() function for each page. The urchinTracker() function is what passes the page URL (along with other visitor information) on to Google Analytics.
To define the urchinTracker() function simply fill in your uniquely defined page URL between the parentheses of the urchinTracker() function, surrounded by single quotes. Example:
urchinTracker(‘/my-unique-page/’);
In this example, “/my-unique-page/” will show up in the Content reports of Google Analytics.
Going back to our initial problem of pages posting back on themselves, your Google Analytics code may look something like this:
The Google Analytics tracking code on the first set of content could look like this:
The Google Analytics tracking code on the second set of content could look like this:
If you use a template system that calls the same Google Analytics tracking code across the whole site, it may not be possible to edit the actual Google Analytics tracking code for each page. To get around this you can call a second urchinTracker() AFTER the original Google Analytics code that loads with content of the page. This may require that you move your Google Analytics tracking code from the bottom of the page to the top of the page. Example:
**Page Content**
It’s important to note that in this case two page views will be counted in Google Analytics. The original urchinTracker() will generate a page view for the URL that is actually in the address bar and the second urchinTracker() will generate a page view for the page you define (In this case, “/my-unique-page/”). We now need to exclude the original URL from the reports, and we do this by creating a filter in Google Analytics with the following settings:
Filter Name: (Name it something descriptive so you can quickly determine what the filter is doing)
Filter Type: Custom FIlter
Select the “Exclude” radio button.
Filter Field: Request URI
Filter Pattern: (The URI that is actually being recorded by Google Analytics)
If you are unsure of how the URI should look, find the page you you are looking for in the “Top Content” report and literally copy and paste the URI that Google Analytics has for the page into the “Filter Pattern” field.
Case Sensitive: Typically this can be set to “No”
Click “Finish”
Thats it! You should now have 1 uniquely defined page in Google Analytics for each set of content that is displayed.



