GoodData
Integrations

Integrating Gooddata with WordPress

Adding Gooddata to your WordPress project is a simple, straightforward process. Follow the step-by-step instructions below to start tracking your visitors without compromising their privacy.

Step 1: Copy Your Project ID

Before you begin, you need your unique Gooddata Project ID.

  1. Log in to your Gooddata Dashboard.
  2. Select your project from the sidebar.
  3. Click on the Settings gear icon in the bottom left.
  4. Copy the Project ID or the provided tracking snippet block.

Step 2: Add the Script to WordPress

There are two primary ways to add code to the header of a WordPress site.

Option 1: Using a Plugin (Easiest)

  1. Log in to your WordPress Admin Dashboard.
  2. Go to Plugins > Add New and search for "WP Headers and Footers" (or any header code injection plugin).
  3. Install and activate the plugin.
  4. Go to the new Settings > WP Headers and Footers menu.
  5. In the "Scripts in Header" box, paste the Gooddata script.
  6. Replace <YOUR_PROJECT_ID> with your ID and click Save.

Option 2: Editing your Theme (Advanced)

If you prefer not to use a plugin, you can edit your theme files directly.

  1. Go to Appearance > Theme File Editor.
  2. On the right sidebar, click on the Theme Functions (functions.php) file.
  3. Scroll to the very bottom and paste the PHP snippet shown below.
  4. Replace <YOUR_PROJECT_ID> with your ID and click Update File.
<!-- Option 1: Using a Plugin (Insert Headers and Footers) -->
<!-- Paste the script in Settings > Insert Headers and Footers > Scripts in Header -->
<script defer data-project-id="<YOUR_PROJECT_ID>" src="https://gooddata-fyp.onrender.com/sdk/tracker.js"></script>


/* Option 2: Add to functions.php */
add_action('wp_head', 'add_gooddata_tracker');
function add_gooddata_tracker() {
    echo '<script defer data-project-id="<YOUR_PROJECT_ID>" src="https://gooddata-fyp.onrender.com/sdk/tracker.js"></script>';
}

Step 3: Verify the Installation

Once you have added the script and published your changes, it's time to test if Gooddata is receiving data.

  1. Open your live website in a new incognito/private browsing window.
  2. Navigate to a few different pages.
  3. Return to your Gooddata Dashboard and go to the Realtime tab.
  4. You should see "1 Active Visitor" and your recent page views populating instantly.

Troubleshooting: If you don't see any data, make sure you don't have an adblocker enabled that might be blocking the script, and ensure you replaced <YOUR_PROJECT_ID> with your actual ID.