Home › Forums › Quform WordPress › Google Client ID
- This topic has 11 replies, 2 voices, and was last updated 8 months ago by Ally.
- AuthorPosts
- March 8, 2024 at 3:45 am #36548vsexmogushiyParticipant
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.
March 8, 2024 at 10:31 am #36551AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 9, 2024 at 12:16 am #36553vsexmogushiyParticipantYou 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?
March 9, 2024 at 8:34 pm #36554vsexmogushiyParticipantUnfortunately, 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 8 months, 2 weeks ago by vsexmogushiy.
Attachments:
You must be logged in to view attached files.March 11, 2024 at 9:12 am #36557AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 11, 2024 at 10:27 pm #36558vsexmogushiyParticipantThank 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.
March 12, 2024 at 11:53 am #36559AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 12, 2024 at 7:47 pm #36560vsexmogushiyParticipantThank 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 8 months, 2 weeks ago by vsexmogushiy.
March 13, 2024 at 10:22 am #36567AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 15, 2024 at 10:21 pm #36595vsexmogushiyParticipantMany Thanks, I try it.
March 23, 2024 at 2:19 pm #36606vsexmogushiyParticipantHello, 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.
March 27, 2024 at 9:51 am #36611AllySupport StaffYou 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 8 months ago by Ally.
- AuthorPosts
- You must be logged in to reply to this topic.