Skip to main content
Solved

Use amplitude experiment in a backend service - Fetch variations without passing a user

  • November 10, 2021
  • 4 replies
  • 651 views

Forum|alt.badge.img
  • New Member
  • 1 reply

A backend service that I am working on needs to be able to perform action A vs action B. 

Is it possible to use amplitude flags to fetch the variant and based on the variant that I get back (A or B) I will perform action A vs action B.

From the developer document, I see that I have to pass in a user object to the `experiment.fetch()` method.

My actions are not tied to any user. I just want to use Amplitude to be able to control the variations. Is that possible ?

Best answer by Denis Holmes

Hi @A.B ,

 

I have contacted the team internally about this question for an answer. Unfortunately, Amplitude was not built for this use case. If you want to randomly assign based on some percentage, you would need to implement this yourself with a Math.random() function or something similar to this yourself to do this!

 

I hope this helps!

View original
Did this topic help you find an answer to your question?

4 replies

Denis Holmes
Team Member
Forum|alt.badge.img+8
  • Team Member
  • 448 replies
  • November 11, 2021

Hi @A.B ,

 

Thanks for writing into Amplitude Community! Always great to see the community being used!

This is a good question. In order to answer your question, can you provide some more info of what you are trying to do exactly? You want to get a variant based on the variant you get back? This should be possible. Can you elaborate a little more on the scenario and what the flow of your current set up is and what you are expecting to happen? This will give me more context of what you are trying to achieve,

 

Thank you, @A.B !

 


Forum|alt.badge.img
  • Author
  • New Member
  • 1 reply
  • November 12, 2021

In my backend service I am calling performing action where I am making a post request to an endpoint A.

Now, I want to be able to send 10% of my requests to endpoint B. This distribution of traffic to endpoint B has nothing to with a ‘user’ or for that matter any other criteria. I just want 10% of the requests to randomly go to endpoint B.

 

Can I use amplitude flags for implementing this ? If so, how do it do it ? I as “how” because the documentation says that I need to provide a “user” object to the `experiment.fetch()` method and I don’t have any user as such. I am randomly distributing requests to another endpoint. I wanna use amplitude, because it gives me the ability to change the distribution, without having to change my code or deploy/rollback my code for any changes. 

 


 


Denis Holmes
Team Member
Forum|alt.badge.img+8
  • Team Member
  • 448 replies
  • November 15, 2021

Hi @A.B !

 

Apologies, I was OOO Friday and I am back in today! Let me speak to my team internally about this and I will get back to you as soon as I can, thank you!

 

 


Denis Holmes
Team Member
Forum|alt.badge.img+8
  • Team Member
  • 448 replies
  • Answer
  • November 16, 2021

Hi @A.B ,

 

I have contacted the team internally about this question for an answer. Unfortunately, Amplitude was not built for this use case. If you want to randomly assign based on some percentage, you would need to implement this yourself with a Math.random() function or something similar to this yourself to do this!

 

I hope this helps!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings