Trouble Tracking Purchases from Agent
Hey! I’ve been trying to solve this for several days, but I’m stuck.
I want to track when a user purchases a product specifically through the agent. Convocore allows creating custom metrics, but I can’t seem to connect WooCommerce orders to whether they originated from the agent or not.
Here’s what I’ve already done:
When a customer clicks a recommended product in the agent, I append /?source=agent to the product URL.
This allows me to detect that the visitor came from the agent.
The problem is that WooCommerce removes this parameter.
When the user clicks “Add to cart”, they are redirected to the product page without the /?source=agent tag.
Because of this, I can’t reliably determine whether a purchase came through the agent.
Does anyone have tips or know how I can fix this? I’m stuck and can’t continue.
Thanks in advance!
7 Replies
Hi! You can persist the source=agent parameter by storing it in a cookie or session when the user lands on the product page, then save it to the WooCommerce order meta at checkout. This ensures every purchase through the agent is tracked in Convocore. I can help implement this so tracking is fully automated. Do you need it to work for both guest and logged-in users?
@Stino12547
@Podziemski Hey, thanks for the answer.Hey I've tried this before but I think I'm doing something wrong. I've added source=agent to the cookie, but it doesn't work. It's not included in the WooCommerce order meta at checkout.
If it already works for logged in users I'm happy with it
Can you provide the code you'll place in the code snipped plugin? I'm using this code now, but it's not working. When I right-click → Inspect → Application → Cookies, it does show Name: _source Value: agent. But in the metadata at checkout there is nothing
Thanks for the update! If the cookie is being created but not showing in the order meta, it means the checkout hook isn’t reading the cookie correctly. I can share a working snippet that captures the _source cookie and writes it into the order metadata for logged-in users. Before I send the code, can you confirm the exact cookie name you’re using (_source or something else)?
@Stino12547
@Podziemski The cookie name I'm using is:
agent_source
Let me know if you need the exact value as well (it's always “agent” when the user comes from the chatbot).
You may want to explore https://dub.co/home
@Podziemski @drbanny101 [Lvl. 2] Thanks but I'd like to keep everything in convocore. I just don't understand why my application above isn't working. I don't think it's that difficult at all, but it doesn't work.
@Podziemski can you provide me the code? 🙂