Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate when webpage uses Snowplow.addPlugin #14

Open
AndersCan opened this issue Mar 30, 2023 · 2 comments
Open

How to integrate when webpage uses Snowplow.addPlugin #14

AndersCan opened this issue Mar 30, 2023 · 2 comments

Comments

@AndersCan
Copy link

AndersCan commented Mar 30, 2023

Context

I have a webpage that is sometimes embedded in a native app (webview). I want to utilise this package to send all events via the native app.

Why: I think it would be better if the native app can attach context about device ID (etc) rather than relying on cookies/id's set in the webview (our GA struggled with this)

Problem

The tracking implemented for the webpage uses Snowplow.addPlugin, but this package does not support addPlugin. How do/should I work around this?

Solutions

Plugin
Initially I thought I could create a plugin that forwarded all events to this packages trackSelfDescribingEvent. However the information received in beforeTrack and/or afterTrack does not appear to be trivial to convert back into Snowplow.trackPageView(...) or Snowplow.trackSelfDescribingEvent(..) (atleast I don't think it is trivial).

Wrapping
The second option I see would be to create a custom wrapper around Snowplow.trackSelfDescribingEvent(...) that also calls the trackSelfDescribingEvent from this package. It seems a bit hacky, so I wanted to hear if there was a better way to do this.

My preferred solution would be the plugin approach, but I'm open to any suggestions.

I also think I would need a way to stop the original event from being tracked, so that I do not create duplicate events. I guess I could get around this by setting the collector url to a non-existing url.

@matus-tomlein
Copy link
Collaborator

Thanks @AndersCan for raising this and sorry for the late reply, this issue has fallen through the cracks.

Adding plugins to the WebView tracker would be a bigger piece of work. However, I do like your idea to pass events from the JavaScript tracker to the WebView tracker using the afterTrack callback in plugins. We could provide the integration in this tracker package and it would be a very nice way to make use of all the features of the JavaScript tracker in the WebView tracker.

@AndersCan
Copy link
Author

@matus-tomlein No worries.

I ended up creating a plugin that converted events back to their original form and then sent them to this plugin. To avoid sending double events, I set the collector url to https://localhost:4004

Would be nice with an official plugin for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants