Highlighted

What's the best way to capture content changing under an ajax/angular framework?

Avatar

Avatar

jeromerichard

Avatar

jeromerichard

jeromerichard

15-10-2015

Hi guys,

I'm working across a site under an angular/ajax framework, and I'm wondering what the best practice is for dealing with this kind of site. In the past under straight s_code I've asked the dev team to populate contextData/custom variables and execute an s.t() with clearVars if needed each time the content loads, triggering a virtual page load. I'd then in my s_code have a bunch of rules and switch statements to set the appropriate props/eVars/events.

Now using DTM, I can see how I could ask for a new js 'analytics' object that captures data like analytics.page and analytics.tool within data elements, however I'm unsure of how to trigger this capture on a location change within the ajax site.

I've looked at the 'element exists' or 'enters viewport' options, such as #location and id="pagename", but I believe I'd then need to set this across each page, and it's a pretty large site 🙂

So, what is the best way of using DTM's functionality to efficiently tag up an ajax/angular based site?

Cheers, Jez

Replies

Highlighted

Avatar

Avatar

Rudi_Shumpert

Employee

Avatar

Rudi_Shumpert

Employee

Rudi_Shumpert
Employee

15-10-2015

You would either use the 'element exists' or 'enters viewport' like to mentioned, or take advantage of our Direct Call Rules.

-Rudi

Highlighted

Avatar

Avatar

Ben_Bytheway

Employee

Avatar

Ben_Bytheway

Employee

Ben_Bytheway
Employee

15-10-2015

Hey Jerome,

I posted this in another question about using DTM in angular (http://help-forums.adobe.com/content/adobeforums/en/analytics-forum/adobe-analytics.topic.html/forum...), but here is what I said:

I don't have any documentation or best practices, but we have done a little bit of tracking with angular and this has come in handy for "page views":

http://michalostruszka.pl/blog/2013/09/24/angularjs-in-browsers-console/
In other words, if you want to hook into a view change event with angular, you could do something like this:
$('appElement').scope().$root.$on('$locationChangeSuccess', function () { console.log(window.location.href); // can use this for page name //s.t(); or s.tl(...); or fire a "direct rule" in DTM });
There are other things you can do from there of course like listening/watching:
https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$watch
And you can use DTM's selectors to do other event based rules as well.
That is the little advice I can give.  🙂
Highlighted

Avatar

Avatar

jeromerichard

Avatar

jeromerichard

jeromerichard

15-10-2015

Thanks bbytheway, that's really helpful - do you know if s.t() and _satellite.pageBottom() are interchangeable?

Highlighted

Avatar

Avatar

jeromerichard

Avatar

jeromerichard

jeromerichard

15-10-2015

Thanks Rudi - I'm liking the direct call rules, and have already used then for some video milestone measurement, is there any down side to using them, or any limits on the number of direct call rules?