Tracking Anchor Links in Goal Funnels

2020-08-01 17:08发布

问题:

On my site I have a form that spans 2 steps each step 1 posts back to the same page and loads the second part of the form. The only difference between step 1 and step 2 in terms of URL is an anchor text in the url

e.g.

STEP 1 : www.mysite.com/enquiry/ STEP 2 : www.mysite.com/enquiry/#message

is it possible to track these in goal funnnels? If not would i have to hardcode some tracking paramater into the GA code?

回答1:

_setAllowAnchor(bool) won't solve your problem; that's a function for allowing Google Analytics to read campaign query strings from the anchor (ie, #utm_medium=cpc.)

This can be hard to do reliably cross-browser without something like jQuery.

You'll need to include a plugin like this to deal with past IE problems: http://benalman.com/code/projects/jquery-hashchange/docs/files/jquery-ba-hashchange-js.html

The following should attach a function to a cross-browser compatible hashchange event, and then create a 'fake' pageview to allow you to track it separately in Google Analytics.

   $(window).hashchange( function() {
       _gaq.push(['_trackPageview',location.pathname+location.search+location.hash]);
    });
});

This should have wider compatibility than some of the other options.

In GA, in your stated example, the 'anchored' page will track as /enquiry/#message.