Add DataFast to your Vue.js project

Follow these steps to integrate DataFast analytics into your Vue.js application.

Add tracking script to main.js

The recommended way to add scripts to all pages in a Vue.js application is by adding it to your main entry file.

  1. Open your project's main file (usually main.js or main.ts).

  2. Add the DataFast tracking script:

    import { createApp } from 'vue'
    import App from './App.vue'
    
    // Add DataFast script
    const script = document.createElement('script')
    script.defer = true
    script.setAttribute('data-website-id', 'YOUR_WEBSITE_ID')
    script.setAttribute('data-domain', 'YOUR_DOMAIN.COM')
    script.src = 'https://datafa.st/js/script.js'
    document.head.appendChild(script)
    
    createApp(App).mount('#app')
    

    Replace YOUR_WEBSITE_ID with your actual Website ID from DataFast. Replace YOUR_DOMAIN.COM with your website's root domain.

Alternative: Using index.html

You can also add the script directly to your index.html file:

<script
  defer
  data-website-id="YOUR_WEBSITE_ID"
  data-domain="YOUR_DOMAIN.COM"
  src="https://datafa.st/js/script.js"
></script>

Verify installation

After implementing either method:

  • Visit your live website
  • Check your DataFast dashboard for incoming data
  • It might take a few minutes for the first pageviews to appear
Something missing? Suggest features ✍️