javascriptreactjsadobe-analyticsadobe-dtm

Page view is not getting triggered in Page view in adobe analytics in SPA


Guys last week am struggling with implementing page view in adobe analytics

These are the things in had done so far

Added adobe scripts in header and added an object like

const data = {
  page: {
    pageInfo: {
      pageName: "",
    },
  },
};

function adobeONPageLoad(name) {
  try {
    if (name !== undefined && email != undefined) {
      data.page.pageInfo.pageName = name;
      window.digitalData = Object.assign(window.digitalData, data);
      console.log("test", window.digitalData);
      window._satellite.track("Page Load");
      return true;
    }
  } catch (error) {
    console.log("error);
  }
}

and added a useEffect in home component and call one of the function like below

  useEffect(() => {
      adobeONPageLoad("Home");
  }, []);

But its not triggering unless i reload page again. Also i do have another tabs , which will show another content but when i navigate to other tabs , no page-view get triggered only exit comes which i guess is the default behavior.

My Requirement is whenever i take another tabs from home page , it should fire new page view in omniture and update the new page name , which is not trigering by default , again when i reload page ,its coming , but i guess its not the right one , i even gave a click function , but that too is not coming in adobe analytics.

Mine is a React SPA application

Any feedback or helps is really appreciated , since am fed up with this


Solution

  • So I was in a similar situation where my Facebook Pixel was firing for the first time and it doesn't fire again after multiple refreshes until a hard refresh(clearing cache) is done. After hours of debugging I found out that was due to a service worker that I registered for making my React app a Progressive Web App. After removing the service worker it worked. Weird thing was even if I remove the code to avoid cache in service worker it was not working, so had to scrap whole service worker file. I think this might be the same situation for any analytics tool.