AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
5.1K members online now
5.1K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

linker:autoLink, decorateForm and useAnchor both set to true doesn't work

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have run into what I think is a bug. in the linker script as documented here: https://developers.google.com/analytics/devguides/collection/analyticsjs/linker

I have set both useAnchor and DecorateForm to true, however when the form is submitted, the client id is not placed in the anchor portion. The documentation seems to indicate that it should.

My GA script:

<script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-8963314-1', 'auto', {'allowLinker': true });
      ga('require', 'linker');
      ga('linker:autoLink', ['negrilhotels.com','donepurple.com'],true,true);
      ga('send', 'pageview');
    </script>

My very simple test form:

<form id="testform" action="http://donepurple.com/test/gatest.html" method="get">
<input type="text" name="hotel" value="10337">
<input type="submit" value="submit">
</form>

The resulting url with querystring: http://www.donepurple.com/test/gatest.html?hotel=10337&_ga=1.136907696.1489615872.1449007290

 

I believe it should be: http://www.donepurple.com/test/gatest.html?hotel=10337#_ga=1.136907696.1489615872.1449007290

You can try it for yourself here: http://www.negrilhotels.com/standalone_booking/booking_widget_test.html

Thoughts? Am I doing something wrong or is this a bug or am I misunderstanding that it's possible?

Re: linker:autoLink, decorateForm and useAnchor both set to true doesn't work

Follower ✭ ✭ ✭
# 2
Follower ✭ ✭ ✭
Hey Margaret,

this is working correctly!

Dont get bogged down by '&' vs. '#' so much... You're fine, as long as "_ga" parameter is appended to the destination URL, with correct client ID information. In-fact it's good its not an anchor '#' parameter, because to the best of my knowledge, GA strips off everything in the URL after '#' '

You can further confirm from Real Time reports, as you fsubmit the firm, the reports should display 1-user, 1-session, 2- pageviews (otherwise it'll show 2-users, 2-sessions-2-pageview.

Hope this helps,

Cheers!

Re: linker:autoLink, decorateForm and useAnchor both set to true doesn't work

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thank you for your reply! The problem is that our booking engine requires the # in front of the _ga parameter. A form submission to them has to look like this:

https://negrilhotels.reservhotel.com/montego-bay-jamaica/samsara-cliff-resort/booking-engine/ibe4.main?DATE_FORMAT=yyyy-mm-dd&hotel=10337&airport=&aDate=2016-09-30&dDate=2016-10-06&rooms=1&adults=2&child=0#_ga=1.136907696.1489615872.1449007290


If I send it with an ampersand instead of a hashtag, then it generates this error: "Illegal PLSQL identifier in input"

I can use javascript to concatenate the querystring with the post object, a hashtag, then the client ID, of course, but it does seem like I shouldn't have to do that. The documentation on linker:autoLink looks to me like it can put the client id in the anchor portion of the url (after a # sign) when decorating a form.

linker:autoLink, decorateForm and useAnchor both set to true doesn&#39;t work

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

@Vibhor J The problem is that the website configuration can require this information to be sent to the anchor portion of the URL rather than the query portion.

 

I have the same issue on a website where adding the _ga parameter in the query portion causes a loading error.

 

@Margaret P Did you finally managed to add it to the anchor portion?