Skip to main content
Web2App - Amplitude analytics script adding
L
Written by Leanid Yuryeu
Updated over a week ago

In this guide we tailor how to insert Amplitude script in your anlyics for regular tracking and cookies policies purposes

Step 1 : Access Your Amplitude API KEL

  1. Go to your Amplitude project

  2. Navigate to Settings > OrganizationSettings > Projects and click the name of the project you’d like to view or edit.

  3. Find the API Key and copy it

Step 2.1 Add Amplitude analytics for Tracking without Cookies policies:

Get the Amplitude script:

<!-- START Load Amplitude Tracking -->
<script type="text/javascript">
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
;r.type="text/javascript"

;r.integrity="sha384-+EO59vL/X7v6VE2s6/F4HxfHlK0nDUVWKVg8K9oUlvffAeeaShVBmbORTC2D3UF+"
;r.crossOrigin="anonymous";r.async=true
;r.src="https://cdn.amplitude.com/libs/amplitude-8.17.0-min.gz.js"
;r.onload=function(){if(!e.amplitude.runQueuedFunctions){console.log("[Amplitude] Error: could not load SDK")}} ;var
i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)
;function s(e,t){e.prototype[t]=function(){

this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
var o=function(){this._q=[];return this}
;var
a=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove"]
;for(var c=0;c<a.length;c++){s(o,a[c])}n.Identify=o;var u=function(){this._q=[]
;return this}
;var
l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
;for(var p=0;p<l.length;p++){s(u,l[p])}n.Revenue=u
;var
d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","enableTracking","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","onInit","logEventWithTimestamp","logEventWithGroups","setSessionId","resetSessionId"]
;function v(e){function t(t){e[t]=function(){
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}
for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){
e=(!e||e.length===0?"$default_instance":e).toLowerCase()

;if(!Object.prototype.hasOwnProperty.call(n._iq,e)){n._iq[e]={_q:[]};v(n._iq[e])
}return n._iq[e]};e.amplitude=n})(window,document);

amplitude.getInstance().init("YOUR_API_KEY");
</script>
<!-- END Load Amplitude Tracking -->

Replace word YOUR_API_KEY in the scipt with your Amplitude API key, that you have copies on your Amplitude project's settings page.

Paste that script in Analytics form in Onboarding online service and click on 'Save Web analytics'

Step 2.2 Add Amplitude analytics for Tracking with Cookies policies:

Click on 'Use Cookies Check'

The needed scripe will be added automatically:

Replace YOUR_AMPLITUDE_ID in the scipt with your Amplitude API key, that you have copied on your Amplitude project's settings page.

Click on Add Web Analtitycs

Did this answer your question?