Expand my Community achievements bar.

SOLVED

at.js 2.x on SPA handling back button

Avatar

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

Avatar

Correct answer by
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

Avatar

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

Avatar

Administrator

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!

Avatar

Correct answer by
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