'Google Analytics Browser Cookie

I have a contact form on a Wordpress website.

When a lead is submitted, I want to capture the Google Analytics ClientID (stored in the _ga cookie in the browser) as part of the submission.

Using this ClientID, I want to interrogate the Google Analytics Reporting API for the first session user activity linked to this lead, fetching the data linked to the following variables:

  • Source

  • Medium

  • Campaign Name

  • Campaign Content

  • Campaign Term

  • Search Query

This is the first time working with the GA API.

Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source