Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

at.js 2.x on SPA handling back button

sambhavj5011451
Level 2
Level 2

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

1 Accepted Solution
sambhavj5011451
Correct answer by
Level 2
Level 2

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

View solution in original post

3 Replies
k_tao
Level 1
Level 1

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

Amelia_Waliany
Employee
Employee

Hi Sambhav! Reaching out to see if you were able to resolve the issue? Thanks for posting and we look forward to hearing from you!

sambhavj5011451
Correct answer by
Level 2
Level 2

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

View solution in original post