luisfarzati/angulartics — pull request #240 by acreeger (2014-11-11 17:48:42+00:00)
Title: Improving path and URL for segment.io in Hashbang mode

My app is in hashbang mode right now. I noticed all the paths in segment.io (& GA indirectly) were being reported as `/`, with the "name" `/user/12345`. This fix manually sets the `url` and `path` properties when the page view is sent to Segment.

A couple of things to note about this PR:
1. It adds `$location` to the call to `trackPageView`. On the one hand, this is a fairly far reaching change, but on the other it makes total sense. It seems reasonable that a plugin should have access to the `$location` object when tracking page views.
2. The `name` property is no longer set on the call to segment. This might be a problem to people that are relying on that functionality (although it is a little inaccurate since it was always being set to the path, which is not the intended use case for the `name` property in segment)

Note I did try something like:

```
$analyticsProvider.registerPageTrack(function (path, $location) {
$injector.invoke(['$location',function($location) {
try {
analytics.page({
path: path,
url: $location.absUrl()
});
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
}]);
});
```

but it was unable to resolve the `$location` service for some reason. Due to time constraints, I took a simpler path.