Question about utag.view and proper usage

Bronze Contributor
Bronze Contributor

When writing an ajax or js-based app with multiple views, what's the best way to maintain the app state with the utag, with regards to analytics. We use Coremetrics and we're currently doing the following (angularJS) route change event.

utag_data.page_type = newRoute.$$route.utag_page_type;
utag_data.page_id = newRoute.$$route.utag_page_id;
utag_data.category_id = newRoute.$$route.utag_category_id;
utag.view(utag_data);

The issue is that the tags fire but some seem to be incorrect or not pulling the configurations that are set to them. In particular, the Coremetrics client ID is not set properly.

Is there anything on the tag template end that needs to be updated in order to make sure the correct data gets sent through when the view is called?

If there's a full API doc of the utag lib and what's at disposal for calling, that'd be helpful as well.

Thanks

2 REPLIES 2

Question about utag.view and proper usage

Employee Emeritus

The way that you are adding the propeties to the data layer wouldnt be correct in this case.
utag_data is the starting data layer that is rendered with the page, utag.data is utag_data but also with any data sources that are defined or manipulated via extensions.
So what you would want to do is:
utag.data.page_type = newRoute.$$route.utag_page_type;
utag.data.page_id = newRoute.$$route.utag_page_id;
utag.data.category_id = newRoute.$$route.utag_category_id;
utag.view(utag.data);

See if that gives you the results you are looking for.

Question about utag.view and proper usage

Bronze Contributor
Bronze Contributor
This was very helpful.
Public