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

SOLVED

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

galynai3258253
Level 1
Level 1

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

 

 

 

1 Accepted Solution
evolytics_brian
Correct answer by
Community Advisor
Community Advisor

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.

View solution in original post

2 Replies
evolytics_brian
Correct answer by
Community Advisor
Community Advisor

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.

View solution in original post

galynai3258253
Level 1
Level 1
Thank you so much for the detailed answer. It is super helpful.