In order to make Alexa work on an Angular based application I downloaded the Alexa code snippet and analyzed it.
it seems that Alexa is relying on this function :
fire: function (e) {
this.user_cookie_v = this.muc();
this.map(e, function (e, t) {
this.opts[e] = t
});
// this.fired() check if "window._atrk_fired" is truthy
if (this.fired()) {
return
}
window._atrk_fired = true;
var t = new Image(1, 1);
t.alt = "alexametrics";
t.src = this.gen_url();
this.cloudfront.fire()
}
Because, in Angular application the page is not reloaded the event fire() is triggered one time only after that "window._atrk_fired" stays truth.
I had to add this code in order to emulate a page reload :
$rootScope.$on( "$routeChangeStart", function(event, next, current) {
console.log('setting alexa fire value to false');
window._atrk_fired = false;
})
I know that this hack is not very reliable because Alexa may change the pageView tracking policy. but my goal was to see if an Angular application can be tracked by Alexa I would like to know your opinion on this matter ?