Hello @J GS happy to help!
You will need to install the Mobile SDKs(iOS, Android) to your app and the webview would need to have the Browser SDK.
I found this piece that was advised previously when it came to bridging both Mobile and Web SDKs that might be helpful:
You can actually achieve this by doing the followings.
- get the session id from the native app
- use JS Bridge to pass the id into in-app browser
- use the JS setSessionId API
It’s also possible to do this with URL params if you don’t want to install the JS Bridge dependency.
From the Android app using the WebView API
long sessionId = Amplitude.getInstance().getSessionId();
myWebView.loadUrl("https://www.example.com?sessionId=" + sessionId);
Then from the webpage, extract the URL param for sessionId and use the JS setSessionId
API.
Also, they also need to provide a way to access the userId from that web page too. It can be done through JS injection to webview.
Thanks for your help! @eddie.gaona
I have understood that native sessionId should be passed to web JS.
Could I question one more about how to track events in mobile web and hybrid app?
Our page can be accessible through web browser and hybrid app. It’s same page.
I want to track events and distinguish the events source (from mobile web or hybrid app).
In this case, how I implement event track method by native sdk or web sdk?
I just thought rough idea. First, I should get JSONobject variable that include events and parameters in webpage JS. Then If the page was opened by hybrid app webview, pass the variable to native SDK track method by using JS bridge. And if the page was opened by web browser, just pass the variable to web SDK track method.
But I’m not sure about that because I didn’t have any experience in hybrid environment.
Could you check the idea is correct and give advice for event tracking?
Or there is a way to get events from web SDK then pass to native SDK?