Angulartics: Google Analytics tracks the complete URI, including anchor

I am using Angulartics and Angulartics Google Analytics [1] to track user flow on an angular page. Event tracking works well. Also, pageview tracking is automatic and works. However, in the Google Analytics toolbar, I don’t see the anchor part of the URL.

Tracking requests are as follows:

https://www.google-analytics.com/collect?
v=1&_v=j51&a=333486222&t=screenview&_s=7&
cd=%2Findex.html%23%2Fsign-in&
dl=http%3A%2F%2Flocalhost%2Findex.html&
ul=de&de=UTF-8&
dt=Treat&
sd=24-bit&sr=1918x941&
vp=1918x845&je=0&
fl=25.0%20r0&an=Treats&_u=SACAAMABO~&jid=&
gjid=&cid=1883662174.1492999789&
uid=Mark-user&tid=UA-9675XXXX-1&z=124537179

Note that the URI part is cd=%2Findex.html%23%2Fsign-inincluded #sign-in, but the important dl=http%3A%2F%2Flocalhost%2Findex.htmlone does not.

My app.js looks like this:

... }).config(function ($analyticsProvider) {
$analyticsProvider.firstPageview(true); /*Records pages that don't use $state or $route*/
$analyticsProvider.withAutoBase(true);  /*Records full path*/
$analyticsProvider.virtualPageviews(true);
});
;

How can I track the full URI, including the anchor for pageviews using Angulartics, without resorting to a manual trigger code?

[1] https://github.com/angulartics/angulartics-google-analytics

[2] https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#location

+6
1

, stateChangeSuccess :

angular.module('starter', ['ionic', ... ,'angulartics',
    'angulartics.google.analytics',
    'angulartics.google.analytics.cordova','angulartics.mixpanel'])

.run(function($rootScope, $state, $analytics, $location){
  $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){

    // we do not use Angulartics virtual pageviews, instead we track them "manually" here because of
    // https://github.com/angulartics/angulartics/issues/550
    // also we track pageviews as events with the pageview path as event name to use the low cost plan of https://mixpanel.com/pricing/

    var currentPath =  $location.path();
    $analytics.pageTrack(currentPath);
    $analytics.eventTrack(currentPath, {category: 'pageview', label: 'pageview'});
  });
});

, $analytics.pageTrack location.path. ! - .

0

Source: https://habr.com/ru/post/1016731/


All Articles