Expand my Community achievements bar.

Join us for the next Community Q&A Coffee Break on Tuesday April 23, 2024 with Eric Matisoff, Principal Evangelist, Analytics & Data Science, who will join us to discuss all the big news and announcements from Summit 2024!
SOLVED

Populating pageviews on a SPA

Avatar

Level 2

The application is in react js and i have done the necessary configuration. But since they have only 1 html page, the page view tags loads first time the user comes in when the user navigates to other pages I do not see page view tag populating. Is there any custom code i need to do.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

That's cause SPA doesn't refresh the page each time, it only changes page content on each view.

I agree with @Alexis on change data element event-based rule, however, that will only work when you have a key in data layer which changes its value on each page. Your best bet is to look for hash change (if your page hash changes each time) otherwise ask dev team to set _satellite.track("pageView") event on each pageview then set a direct call rule with "pageView" in direct-call rules condition. see below.

conditions_direct_call.png

Set Adobe config in the rule as s.t() and add all the necessary page variables in the settings. Also, when using direct-call rule don't forget to add return false; in custom setting under Adobe tool to eliminate double call on the landing page.

View solution in original post

3 Replies

Avatar

Community Advisor

If you have a data Layer and are using Adobe Launch, create a data element that reads the pagename from the data layer and create a rule obn data element change. This will be evaluate each 1 seconds so if the pagename changes based on the datalayer that will be populated each time a page changes in the SPA this will work.

If you are using fragments then create rules to look at has changes.

Otherwise you will have to look online to look at custom code that will have to look at specific DOM element that enters view and fire your code at that time

Avatar

Correct answer by
Community Advisor

That's cause SPA doesn't refresh the page each time, it only changes page content on each view.

I agree with @Alexis on change data element event-based rule, however, that will only work when you have a key in data layer which changes its value on each page. Your best bet is to look for hash change (if your page hash changes each time) otherwise ask dev team to set _satellite.track("pageView") event on each pageview then set a direct call rule with "pageView" in direct-call rules condition. see below.

conditions_direct_call.png

Set Adobe config in the rule as s.t() and add all the necessary page variables in the settings. Also, when using direct-call rule don't forget to add return false; in custom setting under Adobe tool to eliminate double call on the landing page.