Integrate Ghost with Amplitude using code injection and gain a better understanding about what makes your readers tick using reliable site analytics

It's possible to get in-depth site metrics with a seamless Amplitude ย integration for site-wide tracking. Amplitude is a product analytics tool that allows you to understand user behaviour across your site and grow your business. Keep reading to find out how to connect Amplitude to your Ghost site.

Create an Amplitude account

Amplitude offer free and paid-for plans to power your site analytics. If you haven't already, create a new account, verify it and then follow the instructions to create an organisation and a project. Once you're all set up, you're ready to send data from your site to Amplitude.

Copy the Amplitude installation code

Copy the JavaScript SDK Installation code which can be found in the Amplitude setup documentation, or you can copy it directly from here:

<script type="text/javascript">
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
;r.type="text/javascript";r.async=true
;r.src="https://cdn.amplitude.com/libs/amplitude-4.5.2-min.gz.js"
;r.onload=function(){if(e.amplitude.runQueuedFunctions){
e.amplitude.runQueuedFunctions()}else{
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"]
;for(var u=0;u<a.length;u++){s(o,a[u])}n.Identify=o;var c=function(){this._q=[]
;return this}
;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
;for(var p=0;p<l.length;p++){s(c,l[p])}n.Revenue=c
;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","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(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]}
;e.amplitude=n})(window,document);
</script>

Use Ghost Code Injection

In Ghost you can inject code across your entire site or on an individual post or page. Since Amplitude needs to track user behaviour across your entire site, we'll use the global code injection feature which can be found in the Ghost Admin settings menu:

Amplitude requires the tracking code to be in the <head> of each page on your site, so paste it into the Header section and hit save.

That's it! Your site is now fully integrated with Amplitude and you can review your site metrics and start data crunching on the projects dashboard! Create new projects if you need to split up your data into different sections or invite your team to specific reports.

For more detailed information about using Amplitude, check out their Learning Center.