How to replace the analytics.js snippet with the gtag.js snippet in Coldfusion analytics file?
Hello,
I have to replace the analytics.js snippet with the gtag.js snippet for our site. I've reached out to google several times and I get no response or a response that doesn't address my questions.
After looking through documentations I believe we have to install tag into our code, if so where would I do this?https://developers.google.com/analytics/devguides/collection/gtagjs
Then, it asks to migrate it by following this https://developers.google.com/analytics/devguides/migration/ua/analyticsjs-to-gtagjs#analyticsjs_2_gtagjs
but what exactly would I change on our ColdFusion file (code below) to match this : https://developers.google.com/analytics/devguides/migration/ua/analyticsjs-to-gtagjs#analyticsjs_2_gtagjs
I'm not familiar with this. Please help.
This is our google analytics cfm file:
<cftry>
<cfparam name="Request.sTrackFunnelStep" default="">
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create','TAD_ID','auto');
ga('require','ec');
<cfoutput>
<cfif Variables.bTrackReceipt>
<cfloop query="qOfqCart">
ga('ec:addProduct', {
'id': '#courseid#'
,'name': '#JSStringFormat(coursename)#'
,'category': 'Course'
,'brand': 'COMPANY'
<cfif unitprice EQ unitdiscountprice>
,'price':'#unitprice#'
<cfelse>
,'price':'#unitdiscountprice#'
</cfif>
,'quantity': '#quantity#'
});
</cfloop>
ga('ec:setAction', 'purchase', {
'id': '#JSStringFormat(Session.sPersPayInfo.InvoiceNumber)#'
,'affiliation': 'COMPANY'
,'revenue': '#Variables.nTotalPrice#'
,'tax': '#Session.sCartItemTotals.Tax#'
,'shipping': '0'
});
</cfif>
<cfif Len(Request.sTrackFunnelStep)>
ga('send','pageview','#Request.sTrackFunnelStep#');
<cfelse>
ga('send','pageview',location.pathname);
</cfif>
</cfoutput>
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<cfcatch type="Any">
<cfimport taglib="/ctolms1/mail" prefix="mail">
<mail:error-mailer>
</cfcatch>
</cftry>