at.js 2.x on SPA handling back button

sambhavj5011451

06-08-2019

Hi,

I had some experience Targeting Activity running on a react app. I have placed code on URL path change to trigger triggerView() function which is working fine.

I did some personalizations like changing text etc. All of them works fine when I navigate to the views via website clicks.

But when I click on browser back button, it shows the default content of view and not the content coming from Target activity.

Has anyone got similar issue and the way to resolve it.

Thanks

Sambhav

Accepted Solutions (1)

Accepted Solutions (1)

sambhavj5011451

21-10-2019

Hi Amelia,

If we use Launch/DTM to triggerview on URL/hash change detect, then back button will override the original content.

The solution to this is to move the triggerview function in router (in your react app) so that irrespective of from where the view is changed, triggerview will always be triggerred.

Thanks

Sambhav

Answers (2)

Answers (2)

k_tao

01-09-2019

Hi Sambhav,

I had the same issue but have resolved it now. For me, it was because the changes were made on the 'Page load event' in Target rather than on the actual view. This meant that the change only appeared on the initial page load.

Once I added the change to the view picked up by Target, I could see the experience appearing after clicking on the back button.

Cheers,

Karen