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
BedrockMission!

Learn More

View all

Sign in to view all badges

SPA triggerView() handling page reload

Avatar

Avatar
Boost 1
Level 1
KeithF53
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
KeithF53
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
KeithF53
Level 1

24-05-2021

I've created an experience that displays on a SPA triggerView() event. it works as expected the first time that the triggerView() page is loaded or when the app view is changed to that triggerView(). However, if the page displaying the experience called by the triggerView() is reloaded, then the trigger doesn't fire and the experience doesn't display until the triggerView is fired again by navigating the app.

 

I reached out to the team that manages Launch for us and their response was that the triggerView() function is set to fire on URL hash change via Launch. That explains why the trigger and the experience don't fire on page reload, but it doesn't tell me how to ensure that the experience displays on page reload. 

 

Has anyone dealt with a similar problem? What's the solution?

 

Thanks,

Keith

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Boost 10
Level 2
Gaurav_Singh
Level 2

Likes

10 likes

Total Posts

21 posts

Correct Reply

3 solutions
Top badges earned
Boost 10
Affirm 3
Boost 5
Establish
Shape 1
View profile

Avatar
Boost 10
Level 2
Gaurav_Singh
Level 2

Likes

10 likes

Total Posts

21 posts

Correct Reply

3 solutions
Top badges earned
Boost 10
Affirm 3
Boost 5
Establish
Shape 1
View profile
Gaurav_Singh
Level 2

24-05-2021

@KeithF53 I would suggest you create 2 rules in Launch : 

 

1. For page Load request 

2. For view Load request 

 

1. for Page Load request, please try something like : 

Gaurav_Singh_0-1621916273708.png

 

2. For View Load ensure that the view load  on URL hash change :

Gaurav_Singh_1-1621916394252.png

 

Hope this helps.

 

Avatar

Avatar
Give Back 25
Employee
ryanr701
Employee

Likes

197 likes

Total Posts

219 posts

Correct Reply

87 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 25
Employee
ryanr701
Employee

Likes

197 likes

Total Posts

219 posts

Correct Reply

87 solutions
Top badges earned
Give Back 25
Give Back 10
Give Back 5
Give Back 3
Give Back
View profile
ryanr701
Employee

24-05-2021

I'd think you could add a rule in Launch to fire the trigger view on page load if some condition exists (e.g., a hash value is in the url). I've done something similar with JS on the page. Here's my sample code if it is helpful:

<script>
	//add triggerview
	function triggerView(viewName) {
	  // Validate if the Target Libraries are available on your website
	  if (typeof adobe.target.triggerView === 'function') {
		adobe.target.triggerView(viewName);
		console.log('AT: View triggered on page load: '+viewName);
	  } else {
		console.log('AT: triggerView or adobe.target not available but viewName was: '+viewName);
	  }
	}
	//fire triggerView when the SPA loads and when the hash changes in the SPA
	if(window.location.hash.indexOf('mySPAhashValue') >-1){
		triggerView(location.hash);
	}
	window.onhashchange = function() { 
		if(window.location.pathname.indexOf('/mySPApath/') >-1){
			triggerView(location.hash);
		}
	}
</script>