I have a catch 22 situation here with the google analytics tracking code. I have a form that upon submission submits data to an api. We recently decided to record this submission as an ecommerce transaction with the google analytics tracking code. The transaction does not get recorded until the application get submitted and returns data from the api. This is because data from the api is included in the transaction.
The issue is that the form also autosaves data to a database so that if the form is not completely filled out and/or submitted an automated php script can pick it up later for submission to the api.
Now the catch 22
I need to find a way to implement this for the data that is submitted via the automated php script.
3 solutions that won't work
Submitting the the transaction on the serverside to ga. This is possible, but in this scenario all the data that google analytics collects from the client comes from the server which eliminates the whole purpose of using google analytics to begin with.
Submitting the transaction before the form is submitted. Remember we need to retrieve data from the api to submit in the transaction.
Saving information about the client to the database for including in headers when submitting the transaction on the serverside to google analytics. Something like this would probably work that is if I new all the information that google analytics collects about the client, how to spoof my ip address and had the time to build a solution like this.