satellite.track complications in server side rendered react component? | Community
Skip to main content
saml9443
Level 2
December 20, 2019
Solved

satellite.track complications in server side rendered react component?

  • December 20, 2019
  • 2 replies
  • 4061 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Pablo_Childe

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.

 

 

2 replies

harishkumar
Level 2
December 22, 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); };

 

Pablo_Childe
Community Advisor
Pablo_ChildeCommunity AdvisorAccepted solution
Community Advisor
January 22, 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.