https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
i

important-zebra-55422

01/07/2024, 9:36 PM
Hi everyone, Is there a way of knowing only the first time a user is assigned to a particular experiment+variant and not sending that information multiple times for the data engineering team to deduplicate later? For context, in the Python SDK, if I specify a function
on_experiment_viewed
Copy code
def on_experiment_viewed(experiment, result):
  aws_firehose.track(attributes["id"], "Experiment Viewed", {
    'experimentId': experiment.key,
    'variationId': result.key
    "timestamp": now()
  })

# Create a GrowthBook instance
gb = GrowthBook(
  attributes = attributes,
  on_experiment_viewed = on_experiment_viewed,
  api_host = "<https://cdn.growthbook.io>",
  client_key = "<some_key>"
)

gb.load_features()

feature_name = "banner-color"

# Simple on/off feature gating
if gb.is_on(feature_name):
  print("My feature is on!")
else:
  print("My feature is off")
If I run the above code in a script, it'll call our aws firehose each time the script is run, passing the same data(expect for a different
timestamp
)? We'll have to deduplicate it in our data warehouse I believe. Is my understanding correct? If so, is there a way of capturing the first time an user was assigned to a variant only? So if I run the script multiple times, it won't trigger
on_experiment_viewed
. Or any other way you recommend. Maybe, what I want is not a good idea. If so, do let me know.
f

fresh-football-47124

01/08/2024, 6:15 AM
we de-dupe on our queries - assuming you set the right attribution type
you could set some local storage or cookie to track exposure
alternatively you could use the attributes to track something similar, and target to those users (or exclude those users)
i

important-zebra-55422

01/10/2024, 3:24 PM
Thanks Graham
4 Views