Attribute revenue with Ghost
Make sure you've added DataFast tracking to your Ghost site and connected your Stripe account first.
1. Access Ghost Code Injection
- Log in to your Ghost admin dashboard
- Go to Settings > Code Injection
- This is where you'll add the tracking code
2. Add the DataFast tracking code
Paste this JavaScript code in the Site Header section:
<script>
// Track successful member signups and payments
document.addEventListener('DOMContentLoaded', function() {
// Check if this is a successful signup/payment page
if (window.location.href.includes('success') ||
window.location.href.includes('welcome') ||
document.querySelector('[data-members-success]') ||
document.querySelector('.gh-portal-success')) {
// Try to get member email from various sources
const memberEmail = document.querySelector('[data-member-email]')?.textContent ||
document.querySelector('.member-email')?.textContent ||
localStorage.getItem('ghost_member_email');
if (memberEmail && typeof window.datafast === "function") {
window.datafast("payment", { email: memberEmail });
}
}
// Store member email when they sign up for future tracking
const memberForms = document.querySelectorAll('[data-members-form]');
memberForms.forEach(form => {
form.addEventListener('submit', function(e) {
const emailInput = form.querySelector('input[type="email"]');
if (emailInput && emailInput.value) {
localStorage.setItem('ghost_member_email', emailInput.value);
}
});
});
});
</script>
3. Save the settings
Click Save to apply the code injection.
Alternative: Use Zapier (No-code option)
For non-technical users, you can use Zapier to connect Ghost and DataFast:
- Create a Zapier account
- Set up a "Ghost Member Created" trigger
- Connect it to DataFast's Payment API action
- Map the member email to track revenue attribution
This requires no coding and automatically tracks new member signups.
After a successful membership signup, you should see revenue data in your DataFast dashboard. If you don't see attribution data, contact us at marc@datafa.st.