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

satellite.track complications in server side rendered react component?

Avatar

Avatar
Ignite 1
Level 2
saml9443
Level 2

Likes

7 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Ignite 1
Level 2
saml9443
Level 2

Likes

7 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
saml9443
Level 2

20-12-2019

We just launched a new site using a server side rendered react framework. In trying to send some _satellite.track objects (according what I have read to be best practices for a SPA), "_satellite" is undefined.

 

The developers then tried to use window._satelitte but from there they had an error where if a string wasnt passed to the tracker it threw another error so then it became stringified as a JSON object.

 

Does anyone know of issues with sending "_satellite.track" in React? Or are there other methods I am missing? 

 

Thanks!

Analytics launch react satellite.track server side

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Give Back 50
Level 6
pabloc82923542
Level 6

Likes

78 likes

Total Posts

358 posts

Correct Reply

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

Avatar
Give Back 50
Level 6
pabloc82923542
Level 6

Likes

78 likes

Total Posts

358 posts

Correct Reply

82 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
pabloc82923542
Level 6

22-01-2020

As mentioned below a Direct call rule should do the trick.

 

Then depending on desired action first make rule "newPageload" in this case each firing a pageview.

 

Then make sure your SPA for each new state change(virtual page load) fires the rule:

 

_satellite.track("newPageload")

 

as long as app fires it when desired(up to you and devs) then teh action will fire your code.

 

2 things to watch out for:

 

Make sure satellite track and all elements are page ready before page bottom.

On some SPAs the initial load may double fire so you may need to suppress it.

 

 

Avatar

Avatar
Boost 1
Level 1
harishkumar
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile

Avatar
Boost 1
Level 1
harishkumar
Level 1

Likes

2 likes

Total Posts

11 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Affirm 1
View profile
harishkumar
Level 1

22-12-2019

I am not sure of direct call rule working with react code or not but you can create customEvent() in react code and then using Launch core extension, create a event customEvent which will identify the custom event value and fire the launch rule on user action. 

 

Example Sample code for javascript is :

var viewEndCustomEvent = function viewEndCustomEvent() {
	  var event = new CustomEvent('event-view-end');
	  var obj = document.querySelector("#spa");
obj.dispatchEvent(event); };