I want to store Google Adwords gclid parameter to Woocommerce Database. Any idea how can I do this. I want to create a new field in the Woocommerce orders to store the gclid if its present.
Onclick place order button, I want to store the gclid into woocommerce order(database and backend) if its present.
2
Answers
I have done this with below code:
I would store the gclid in WooCommerce session storage (you can check on each page load if the gclid is set in URL and doesn’t exist yet in WC session storage) like this:
Then, you can store the gclid as an order meta after it is created like this:
Then you can do anything you want with this meta (display in in the dashboard, etc.).