Google Tag Manager - Passing Cookie data into PerchFrom fields

  • Hiya,

    Ok so I have a bit of an odd query here.

    I have to track Google UTM variables offline to get positive conversions on actual sales.

    In GTM I have set session cookies to pull all the data I need from Google Ads clicks off the URL, I now need to extract the data from the cookie and place it into the Perch Form fields so I can forward the data to my sales team.

    Normally I would simply do this with javascript in GTM by pushing the data into a hidden field via getElementById() method, triggered on page load, but the form is not picking up on it.

    My skills in perch are still extremely basic so any pointers on how I can get this done would be hugely appreciated.

    I am pretty sure it has to do with a timing issue of codes firing at the wrong time, but I wanted to put this out here in case anyone has a quick fix or a precedent.

    I could not find anything posted.

    Thank you:P :burd1::burd1fly::burd1peck:

    PS: I can pull the UTM data out of the url via GET and populate the Perch Form, but then I would have to pull the data from the cookie put it in the url and pull it back into the form that way. There must be a way to get this straight out of the cookie ... no?

  • OMG I am such an idiot... I would say ignore my post, but then may be someone may learn from it

    You can import Google Tag Manager cookie values into a PerchForm like this

    1. $utm_content = $_COOKIE['utm_content'];
    2. PerchSystem::set_var('myContent', $utm_content);
    3. $utm_campaign = $_COOKIE['utm_campaign'];
    4. PerchSystem::set_var('myCampaign', $utm_campaign);
    5. $utm_term = $_COOKIE['utm_term'];
    6. PerchSystem::set_var('myTerm', $utm_term);
    7. $utm_medium = $_COOKIE['utm_medium'];
    8. PerchSystem::set_var('myMedium', $utm_medium);
    9. $utm_source = $_COOKIE['utm_source'];
    10. PerchSystem::set_var('mySource', $utm_source);

    pushing them into hidden input fields and passing on the data

    It is a Given the cookies and UTM tracking needs to be set up in GTM

  • drewm

    Approved the thread.
  • Or, doing the same thing in a more readable way:

    1. PerchSystem::set_vars([
    2. 'myContent' => $_COOKIE['utm_content'],
    3. 'myCampaign' => $_COOKIE['utm_campaign'],
    4. 'myTerm' => $_COOKIE['utm_term'],
    5. 'myMedium' => $_COOKIE['utm_medium'],
    6. 'mySource' => $_COOKIE['utm_source'],
    7. ]);