1234567891011121314151617181920212223242526272829 |
- from fastapi import FastAPI
- import uvicorn
- from ga4mp import GtagMP
- from ga4mp.store import DictStore
- ## ai.choozmo.com
- app = FastAPI()
- @app.get("/ga")
- async def root(utm_source, utm_medium,utm_campaign,utm_term):
- print(utm_source)
- print(utm_medium)
- print(utm_campaign)
- print(utm_term)
- test_event=None
- gtag_tracker=None
- gtag_tracker = GtagMP(api_secret='PPx-W5JUQuSgx6B3QZeisA', measurement_id='G-G5H9MMGQFM', client_id=utm_term)
- test_event = gtag_tracker.create_new_event(name="edm")
- test_event.set_event_param(name="campaign", value=utm_campaign)
- test_event.set_event_param(name="email", value=utm_term)
- test_event.set_event_param(name="label", value=utm_term)
- gtag_tracker.store.set_user_property(name="jtest", value="yes")
- event_list = [test_event]
- gtag_tracker.send(events=event_list)
- return {"message": "Hello World"}
- if __name__ == "__main__":
- uvicorn.run("fapitest:app", host="0.0.0.0", port=8899)
-
- #http://localhost:8899/ga?utm_source=newsletter&utm_medium=email&utm_campaign=test&utm_term=t2&utm_content=ccc
|