trigger adobeDataLayer push before navigation changes page URL | Community
Skip to main content
May 28, 2024
Solved

trigger adobeDataLayer push before navigation changes page URL

  • May 28, 2024
  • 1 reply
  • 2103 views

Hey team,

 

We are trying to use adobeDataLayer.push() when we make click on a button that redirects to other route, the issue is that when we trigger adobeDataLayer.push() and then we make the redirection adobeDataLayer takes the next page URL, I'm looking for a callback or something to can wait for push method to execute our redirection after. Any suggestion please?

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 bjoern__koth

Hi @pedroci 

in general I would say the Page URL is not really relevant as long as your other analytics dimensions like pageName, props and eVars are set.

If this is relevant to you, you could as a workaround tell your adobeDataLayer push event the correct pageURL and overwrite the analytics attribute with it 

 

 

// assuming you have something like this adobeDataLayer.push({ event: "myEvent", eventInfo: { pageURL: "https://example.com" } })

 

 

 

// and then in the rule that is processing the ACDL push, use an adobe analytics "set variables" action's custom code call this s.pageURL = event?.message?.eventInfo?.pageURL;

 

 

https://experienceleague.adobe.com/en/docs/analytics/implementation/vars/page-vars/pageurl 

 

Let me know if that works.

 

Side note: this functionality is particularly interesting if you need to clean up the captured URL from unwanted parameters like PII.

1 reply

bjoern__koth
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 28, 2024

Hi @pedroci 

what exactly do you mean with "adobeDataLayer takes the next page URL"?

Are we talking about a SPA that pushes a state into the history stack or an actual redirect to a new page?

Because latter will rather cause an aborted request and the new request you see might just be the page view on the following page that is triggered.

General questions: Are you using WebSDK / Edge Network forwarding or the classic AppMeasurement Analytics library?


And which field in your Analytics request are you referring to that is incorrectly set to the new URL?

Normally, the URL itself should not matter much and most fields can anyway be overwritten as needed. 

 

Bottom line, I do not think you need a callback to listen to or delay the navigation accordingly.

 

Cheers

Cheers from Switzerland!
PedroCiAuthor
May 28, 2024

Hi @bjoern__koth 

I think I'm using the classic library because I'm using window object to trigger adobe analytics methods, yes it's a SPA, I'm trying to track data when the user makes click in a button, this button trigger an internal redirection, I'm sending data to window.adobeDataLayer.push({...data}) but when I checked the data on Adobe experience platform debugger (chrome plugin) I see that the Page URL is different, looks like takes the URL from the next page because probably the push method takes more time than the redirection and takes the page url from window object I think. I'm looking a way to wait for window.adobeDataLayer.push({...data}) and then trigger the redirect method

 

 

bjoern__koth
Community Advisor and Adobe Champion
bjoern__kothCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 29, 2024

Hi @pedroci 

in general I would say the Page URL is not really relevant as long as your other analytics dimensions like pageName, props and eVars are set.

If this is relevant to you, you could as a workaround tell your adobeDataLayer push event the correct pageURL and overwrite the analytics attribute with it 

 

 

// assuming you have something like this adobeDataLayer.push({ event: "myEvent", eventInfo: { pageURL: "https://example.com" } })

 

 

 

// and then in the rule that is processing the ACDL push, use an adobe analytics "set variables" action's custom code call this s.pageURL = event?.message?.eventInfo?.pageURL;

 

 

https://experienceleague.adobe.com/en/docs/analytics/implementation/vars/page-vars/pageurl 

 

Let me know if that works.

 

Side note: this functionality is particularly interesting if you need to clean up the captured URL from unwanted parameters like PII.

Cheers from Switzerland!