Skip to main content

Hello,

I am currently using the python sdk to track all of my events. I want to start tracking the utm information and initial referrer. I see that its easy with some settings on the javascript sdk. 

1. Should I try to implement it in the python sdk or add on a js implementation

  1. If I add in a js implementation then how do I make sure it integrates with the same user flow as the python implementation 
  2. how do I implement js to ensure utm and referrer tracking
Hi Micah,

To track UTM parameters and referrers, you can indeed use the JavaScript SDK. This is because UTM parameters and referrers are typically captured from the URL and HTTP headers of the user's browser request, which is something the JavaScript SDK is designed to handle.
Here's how you can set it up:

1. Initialize the JavaScript SDK on your webpage. You can find the details on how to do this in the Amplitude JavaScript SDK documentation: https://developers.amplitude.com/docs/javascript
2. As part of the initialization configuration, set `includeUtm` and `includeReferrer` to `true`. This will enable the SDK to automatically capture UTM parameters and referrers. Here's an example:

amplitude.getInstance().init('YOUR_API_KEY_HERE', null, { includeUtm: true, includeReferrer: true});

Remember to replace `'YOUR_API_KEY_HERE'` with your actual API key.

As for integrating this with your existing Python SDK implementation, the key is to ensure consistent user identification across both SDKs. If you're using a user ID to identify users in the Python SDK, you should set the same user ID in the JavaScript SDK using the `setUserId` method. Here's an example:

amplitude.getInstance().setUserId('USER_ID_HERE');

Again, replace `'USER_ID_HERE'` with the actual user ID.

By doing this, events logged by both the Python SDK and the JavaScript SDK will be associated with the same user in Amplitude, allowing you to track the user's journey across both server-side and client-side interactions.

I hope this helps! Let me know if you have any other questions.

Best,
Yosimy


P.S. Checkout upcoming events and user meetups on our events page.

Reply