Is it possible to determine whether a user has come to your website via an organic search or direct and is it then possible to store this in our database?
We have a form on our website so essentially we want to find out if the user came direct or via organic search and then pass this in with the form to store 'organic' or 'direct' in our database for each enquiry.
E.g if user ABC came via direct and filled in the form they would be stored in the database as name = ABC, referral = direct, enquiry = test.
If user XYZ came via organic and filled in the form they would be stored in the database as name = XYZ, referral = organic, enquiry = test.
As I understand it, you are trying to pass a value stored within the GA cookie to your CRM database. If so, there are a number of ways you could accomplish what you are looking for.
Like others have said, I would recommend parsing the data from the cookie. There's also the _link() or for you, the _linkByPost() function which will append the cookie information as URL parameters. Perhaps then you could take the values from the URL parameters: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._linkByPost
In this case, you would have a script on the form confirmation URL that would listen to the URL parameters than contain referrer information, and pass that along to your database. Here is an example of what that URL would look like:
Have you considered using the API? That might be another option. Check out this API tool, it's quite helpful: http://ga-dev-tools.appspot.com/explorer/.
Can you provide a snippet of the code that's storing the values associated with a given user?