-
- // CAPTURE GOOGLE CAMPAIGN VARIABLES INTO COOKIE var my_utm_source; var my_utm_medium; var my_utm_term; var my_utm_content; var my_utm_campaign; my_utm_source = getParameterByName("utm_source"); my_utm_medium = getParameterByName("utm_medium"); my_utm_term = getParameterByName("utm_term"); my_utm_content = getParameterByName("utm_content"); my_utm_campaign = getParameterByName("utm_campaign"); if (my_utm_source) $.cookie('cookie_utm_source', my_utm_source, { expires: 7, domain: 'apptio.com',path: '/' }); if (my_utm_medium) $.cookie('cookie_utm_medium', my_utm_medium, { expires: 7, domain: 'apptio.com',path: '/' }); if (my_utm_term) $.cookie('cookie_utm_term', my_utm_term, { expires: 7, domain: 'apptio.com',path: '/' }); if (my_utm_content) $.cookie('cookie_utm_content', my_utm_content, { expires: 7, domain: 'apptio.com',path: '/' }); if (my_utm_campaign) $.cookie('cookie_utm_campaign', my_utm_campaign, { expires: 7, domain: 'apptio.com',path: '/' }); function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } // END CAPTURE GOOGLE CAMPAIGN DATA INTO COOKIES // HANDLE COOKIE VALUES FROM GOOGLE CAMPAIGNS function goPopulateCampaignFields() { if ($.cookie('cookie_utm_source') && document.getElementById('utm_source__c')) document.getElementById('utm_source__c').value=$.cookie('cookie_utm_source'); if ($.cookie('cookie_utm_medium') && document.getElementById('utm_medium__c')) document.getElementById('utm_medium__c').value=$.cookie('cookie_utm_medium'); if ($.cookie('cookie_utm_term') && document.getElementById('utm_term__c')) document.getElementById('utm_term__c').value=$.cookie('cookie_utm_term'); if ($.cookie('cookie_utm_content') && document.getElementById('utm_content__c')) document.getElementById('utm_content__c').value=$.cookie('cookie_utm_content'); if ($.cookie('cookie_utm_campaign') && document.getElementById('utm_campaign__c')) document.getElementById('utm_campaign__c').value=$.cookie('cookie_utm_campaign'); //TESTING ONLY //document.getElementById('testDiv').innerHTML = $.cookie('cookie_utm_source')+$.cookie('cookie_utm_medium')+$.cookie('cookie_utm_term')+$.cookie('cookie_utm_content')+$.cookie('cookie_utm_content'); } goPopulateCampaignFields();