runt18 / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

GA/GTM cross-domain tracking code inserted incorrectly, breaking URLs #876

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
We are Zooniverse (http://zooniverse.org/), a citizen science platform, and we 
are using Google Tag Manager on our various websites for tracking users as they 
move between our different sites.

Unfortunately, it seems that Google Tag Manager is incorrectly modifying our 
URLs when it tries to insert the cross domain tracking cookie, which is 
producing links that are broken/not resolvable when the user clicks on them.

For example, the URL 
http://talk.asteroidzoo.org/#/boards/BAZ0000001/discussions/DAZ000070l?page=4&co
mment_id=56b859bff724d723aa00149f

gets changed to 
http://talk.asteroidzoo.org/&_ga=1.188290792.1317726597.1426697521#/boards/BAZ00
00001/discussions/DAZ000070l?page=4&comment_id=56b859bff724d723aa00149f

which is invalid

We do use ? and & within our fragment identifier, but this is completely valid 
per the RFC (see Appendix A of http://tools.ietf.org/html/rfc3986 , boiled down 
in a more easy to read format here http://stackoverflow.com/a/2849800/971500 )

This could be easily fixed by ensuring that if the URI (excluding the fragment 
ID) doesn't have a question mark, that you add one. In other words this URL 
would become:

http://talk.asteroidzoo.org/&_ga=1.188290792.1317726597.1426697521#/boards/BAZ00
00001/discussions/DAZ000070l?page=4&comment_id=56b859bff724d723aa00149f

which is valid. 
I think perhaps your code is checking for the presence of ? anywhere in the URI 
to determine if it should add one, whereas it should look only in the base URI.

If this is not the right place to report this issue, please let me know where I 
should post it.

Original issue reported on code.google.com by alex.bow...@zooniverse.org on 12 Feb 2016 at 3:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Sorry, slight typo in the above. the correct URL that *should* be produced (URL 
at the end) is:

http://talk.asteroidzoo.org/?_ga=1.203108369.1257499081.1450219232#/boards/BAZ00
00001/discussions/DAZ000070l?page=4&comment_id=56b865a0f724d764370041c2

Original comment by alex.bow...@zooniverse.org on 12 Feb 2016 at 4:01