I made a form in our website with hidden fields for tracking and saving Google Analytics Client ID and Google Adwords Click ID. I grab both ID's with 2 scripts and put them into my hidden fields and save them on my server.
When a user visits the website by organic traffic only the Analytics ID will be saved and send to Google, no problem.
But when a user visits my website by Adwords advertising, my website grabs both ID's.
The scripts for saving the id's:
<script type="text/javascript">
// Set gclid Cookie
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;
}
function getParam(p){
var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
var gclid = getParam('gclid');
if(gclid){
var gclsrc = getParam('gclsrc');
if(!gclsrc || gclsrc.indexOf('aw') !== -1){
setCookie('gclid', gclid, 90);
}
}
// Save gclid Cookie
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('gclid_field').value = readCookie('gclid');
}
// Analytics Client ID in hidden field
$(document).ready( function() {
// Makes use of the Universal Analytics API 'ga' object
ga(function(tracker) {
var clientId = tracker.get('clientId');
$("#clientid_field").val(clientId);
});
});
An example of the 2 saved id's
We send the ID's to Analytics and Adwords with a revenue to measure offline conversion, but my question is: Does the 2 ID's conflict each other when you both send them to Google, so you got double measuring?