Direct call rules in SPA (Single Page Application) async deployment | Community
Skip to main content
September 16, 2020
Solved

Direct call rules in SPA (Single Page Application) async deployment

  • September 16, 2020
  • 1 reply
  • 1807 views

Hello 🙂 

 

We use _satellite.track to track pageviews in the Single Page Application while the Adobe script loads asyncronously. As expected, sometimes we get error message: _satellite is not defined. It means that the _satellite.track had been fired before the script finished loading.

 

What is the best way to solve this issue technically? Is there any method recommended by Adobe? 

 

Thank you in advance.

Galyna

 

 

 

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 Brian_Johnson_

I think the only real option here is to code around the context of your site. Before calling _satellite.track(), make sure it exists. This could be done in various ways...

  • Define your data layer on the page and move the _satellite.track() call into Launch.
  • Create an interval that continuously checks for the _satellite object, only calling _satellite.track() when you're certain it exists on the page.
  • Create a page load rule that notifies the page that _satellite has loaded and is ready to go. When that rule fires, use it to trigger your _satellite.track() call(s) by emitting a custom JS event that can be subscribed to with a simple document.addEventListener() in your page content. (Or, set a JS variable on the window that, when present/populated, tells the page that you're ready for the _satellite.track() calls to fire.)

You have a lot of options, but at the end of the day, it's just a timing challenge, and you'll have to decide what fits best in your environment.

1 reply

Brian_Johnson_
Brian_Johnson_Accepted solution
September 16, 2020

I think the only real option here is to code around the context of your site. Before calling _satellite.track(), make sure it exists. This could be done in various ways...

  • Define your data layer on the page and move the _satellite.track() call into Launch.
  • Create an interval that continuously checks for the _satellite object, only calling _satellite.track() when you're certain it exists on the page.
  • Create a page load rule that notifies the page that _satellite has loaded and is ready to go. When that rule fires, use it to trigger your _satellite.track() call(s) by emitting a custom JS event that can be subscribed to with a simple document.addEventListener() in your page content. (Or, set a JS variable on the window that, when present/populated, tells the page that you're ready for the _satellite.track() calls to fire.)

You have a lot of options, but at the end of the day, it's just a timing challenge, and you'll have to decide what fits best in your environment.

September 17, 2020
Thank you so much for the detailed answer. It is super helpful.