Expand my Community achievements bar.

SOLVED

Reactjs

Avatar

Level 5

Is there any documentation on integration of Adobe Analytics (through javascript not through Launch / DTM) with reactjs SPA (not react-native just plain reactjs)? Or any npm module which helps with the same?

 

For e.g. here's a module which helps with integration of Google Analytics with react:

https://github.com/react-ga/react-ga

Anything similar for Adobe Analytics?

 

I tried including appmeasurement.js and calling s.t() from within react code but the code wouldn't compile on doing that.

1 Accepted Solution

Avatar

Correct answer by
Level 2
3 Replies

Avatar

Level 2

Hi @jakej40603950,

 

I'm familiar with some GTA/GA React packages, but have not seen similar offerings for Adobe Analytics.

 

To start, I recommend a solid understanding of the AppMeasurement library. Check out the official implementation guide here. In particular, look at the initialization (steps 1-3) which you can do in your main App component, then you can call s.t() in componentDidMount or via a hook of router components.

 

As for the code not compiling, what error is it throwing? Are you putting the AppMeasurement.js in the public folder?

 

-Miguel

Avatar

Level 5

Thanks a lot for the reply.

Error was due to not including s.tl() inside a script tag. But even after correcting it and putting it inside componentDidMount, the current URL being passed is always the parent one. The route changes seem to have no effect. You know if there's a way to fix that?

Avatar

Correct answer by
Level 2
For overriding the page URL try the s.pageURL = "https://example.com"; method. See here for more info https://docs.adobe.com/content/help/en/analytics/implementation/vars/page-vars/pageurl.html