Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Can trailing slash be removed on _trackPageView Google Analytics #158

Open
diggersworld opened this Issue · 7 comments

3 participants

@diggersworld

I've set my site up so that .htaccess removes trailing slashes.

Initially I had a problem where page views were being sent twice due to having the $.address plugin installed. I removed the _trackPageView from the original GA code which solved the duplicate reporting.

However so far I haven't been able to figure out why the $.address plugin always adds a trailing slash on the end of the page parameter. Using the GA Debug extension in Chrome I can see the value being passed as:

_gaq.push processing "_trackPageview" for args: "[/projects/]":

When it should be:

_gaq.push processing "_trackPageview" for args: "[/projects]":

The original GA script had no problem with the lack of trailing slash, so I gathered it must be the plugin doing it.

Is there a way to resolve this issue?

@asual
Owner

Most of the online samples take advantage of use GA but I can't see this behavior.

Here are some samples:
http://www.asual.com/jquery/address/samples/events/#about
http://www.asual.com/jquery/address/samples/state/about
http://www.asual.com/jquery/address/samples/api/#/section/2 (the track function dumps the value in the content area)

The __utm.gif request params doesn't include a value with a trailing slash.

@diggersworld

Okay... I will try using those links to figure out what's going on.
I've noticed that even URL with get variables in them are having trailing slashes appended like so:

_gaq.push processing "_trackPageview" for args: "[/projects?category=games/]":

@diggersworld

Hmmm.... I'm attempting to isolate the problem, so what I've done is create a local test environment with just the bare essentials in it. So I have a HTML file which loads jQuery, the jquery-address plugin and has the Google Analytics script, with _trackPageview removed (to stop duplication).

The URL I hit is: http://local.google-analytics.com/address-plugin/index.html

Using the Google Analytics debugger I still see the "_setPageview" value being pushed with a trailing slash.
This appears to occur simply by including the library (jquery.address-1.5.min.js).

I've attached a screenshot of the debug info:

ga-jquery-address-debug

@diggersworld

A little more info. It only appears to be an issue when looking at the default URL of the page. If it's a link request through the jquery-address plugin then it seems to work fine. But when you're at the root path, i.e. yet to click a link that is binded to the $.address plugin, that is where the issue lies.

This is true of the example code you linked me to as well, which I have got running locally.

@jontro

Speaking of, I do not think jquery adress should do anything by default if not initialized. Currently the plugin does an extra trackpageview if it's only included. Cannot track by default be set to null?

@diggersworld

From what I understand "The jQuery Address plugin does not require initialization." - http://www.asual.com/jquery/address/docs/ under API reference.
I assume that to mean it automatically starts performing actions (including the tracking).

If I was to set track by default to null.
I would then need to add conditions across my site to use the default tracking code when not using $.address plugin and then to remove it when using the plugin, which is a bit awkward really.

@jontro

diggersworld, I guess it's depends on your point of view. I certainly does not expect including a js file to add extra trackPageViews for the entire site by default. It would be a lot less intrusive if the default is do not track. You can always set the defaults by adding ?tracker=track url parameters.

The reason the extra slash is appended is because of strict mode being enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.