luisfarzati/angulartics — pull request #46 by enricopulatzo (2013-09-25 14:04:53+00:00)
Title: exposing $http for custom third-party integration

In order to write a third-party integration that is angular based (i.e. does not already use a global object to talk to a back-end), I'd like to expose the $http service to the $analyticsProvider.

When done, one can then send requests to a back-end like so:
$analyticsProvider.registerPageTrack( function ( path ) {
this.httpService.post(
"ng_analytics/page",
{ "path": path },
{ headers: {'Content-Type': 'application/x-www-form-urlencoded'} }
);
} );
$analyticsProvider.registerEventTrack( function ( action, properties ) {
this.httpService.post(
"ng_analytics/event",
{ "action": action, "properties": angular.toJson( properties ) },
{ headers: {'Content-Type': 'application/x-www-form-urlencoded'} }
);
} );

p.s. I tried sending this yesterday, but I don't think the request completed; forgive me if you see this twice.