Google Client ID

Home Forums Quform WordPress Google Client ID

This topic is: resolved
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #36548
    vsexmogushiy
    Participant

    Hello, tell me please how I can correctly add Google Client ID in form?

    I have this code:

    <script type="application/javascript">
    function getYClientID() {
    var match = document.cookie.match('(?:^|;)\\s*_ym_uid=([^;]*)');
    return (match) ? decodeURIComponent(match[1]) : false;
    }

    function getGoogleClientID()
    {
    var match = document.cookie.match('(?:^|;)\\s*_ga=([^;]*)');
    var raw = (match) ? decodeURIComponent(match[1]) : null;
    if (raw)
    {
    match = raw.match(/(\d+\.\d+)$/);
    }
    var gacid = (match) ? match[1] : null;
    if (gacid)
    {
    return gacid;
    }
    }

    document.addEventListener('DOMContentLoaded', function(){
    document.getElementById('cid').value=getGoogleClientID();
    document.getElementById('ycid').value=getYClientID();
    });

    However, in my forms this code don’t working,

    Please tell me step by step.

    #36551
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #36553
    vsexmogushiy
    Participant

    You are absolutely right about the hidden fields. That is, if I understood correctly, I just need to add the script specified by yours, where forms can open on the site.

    And in order for the necessary parameters from this script to work, get Google Client ID() and getYClientID(). Do I need to add custom JS to the section?

    #36554
    vsexmogushiy
    Participant

    Unfortunately, I can’t transfer the data correctly (nothing works), so I ask you to look at the route and show me what the problem is.

    1. Go to the Yandex Metrcia — https://yandex.ru/support/metrica/objects/get-client-id.html?lang=en;

    Cope example code:
    ym(93307677, 'getClientID', function(clientID) {
      document.getElementById('clientID').value = clientID;
    });

    2. Add JS file with this code and connect my site (https://laptova.ru/scripts/clientid_userid_yclid.js).

    3. Add hidden fields in my forms with dynamic value, default value, without value. Add this code to Custom JavaScript:

    jQuery(function ($) {
        $('.quform-field-6_43, .quform-field-6_39. .quform-field-6_47').val(
            clientID()
        );
    });

    How I can send ClientID in my forms and how I can make it optimal?

    • This reply was modified 9 months, 2 weeks ago by vsexmogushiy.
    Attachments:
    You must be logged in to view attached files.
    #36557
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #36558
    vsexmogushiy
    Participant

    Thank you very much. It works.

    And one more thing. Tell please how I can add Yclid (step by step):

    STEP 1. Go to the Yandex Metrcia — https://yandex.ru/support/metrica/data/get-yclid.html?lang=en#null . Copy and insert example code every page:

    <script type="text/javascript">
    function setCookie(name, value, days){
    var date = new Date();
    date.setTime(date.getTime() + (days*24*60*60*1000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = name + "=" + value + expires + ";path=/";
    }
    function getParam(p){
    var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
    }
    var yclid = getParam('yclid');
    if(yclid){
    setCookie('yclid', yclid, 90);
    }
    </script>

    STEP 2. GET Yclid.

    <form action="" name="myForm">
    Name: <input type="text" name="name">
    <!--Скрытое поле для извлечения yclid-->
    <input type="hidden" id="yclid_field" name="yclid_field" value="">
    <input type="submit" value="Submit Form" name="btnSubmit">
    </form>

    <!--Извлечение yclid и изменение скрытого поля-->
    <script>
    function readCookie(name) {
    var n = name + "=";
    var cookie = document.cookie.split(';');
    for(var i=0;i < cookie.length;i++) {
    var c = cookie[i];
    while (c.charAt(0)==' '){c = c.substring(1,c.length);}
    if (c.indexOf(n) == 0){return c.substring(n.length,c.length);}
    }
    return null;
    }
    window.onload = function() {
    document.getElementById('yclid_field').value =
    readCookie('yclid');
    }
    </script>

    How I can do this correctly?
    ——————————————————————

    And if you have the opportunity to tell me how to find out how to insert a Google Client ID into the form, as well as tell me how to set the UTM parameters (campaign, source, term and other) correctly in a separate field. I will be extremely grateful to you.

    #36559
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #36560
    vsexmogushiy
    Participant

    Thank you very much, it seems to be working. We will check it out as soon as possible. And in order for everything to be set up correctly, maybe you can tell me how to correctly take the Google Client ID (that is, not gclid, but cid, which is what _ga calls in cookies).

    You can also specify in a separate hidden field what comes after the link sign with UTM or other parameters (that is, after the sign ?).

    • This reply was modified 9 months, 2 weeks ago by vsexmogushiy.
    #36567
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #36595
    vsexmogushiy
    Participant

    Many Thanks, I try it.

    #36606
    vsexmogushiy
    Participant

    Hello, once again, thank you very much and bow low. But here’s what I would like to know, how, if, for example, the same UTM tags are not on the page, to send the default value: no. This is the default value, but unfortunately in the form (if there are no values) They don’t come. And I would like to receive just the no value specified by default, please tell me how to do this.

    #36611
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    • This reply was modified 9 months ago by Ally.
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy