Skip to main content
Install code using Wordpress

In this article we explain how to install the SourceGeek tracking code on a Wordpress website.

Updated this week

If you use Wordpress as a CMS where your job offers are on, follow one of these methods to install our tracking code on your pages.

For details about Wordpress and their support, please visit their website.

Table of contents:

Method 1: Install a plug-in

Plugins provide an easy way to extend the functionality of your WordPress site without touching any code.

Advantage

  • Ease of use: Allows non-technical users to add custom code without editing theme files or understanding PHP.

  • Safety: Minimizes the risk of breaking your site by incorrectly editing PHP files directly.

  • Persistence: Code snippets added via WP Code remain active and are not lost even when you switch themes, ensuring continuity of functionality.

Depending on the plugin, after installation you may need to access it via the settings menu or it may add a new menu item to the left sidebar. For this blog, we will be using WP Code.

The WP Code plugin, formerly known as Insert Headers and Footers by WP Beginner, is a WordPress plugin that simplifies the process of adding code snippets to your WordPress site, particularly in the header, body, and footer sections. This plugin is commonly used to insert JavaScript, CSS, HTML, or PHP code that can influence the appearance or behavior of the entire site without directly editing theme files. Here’s a detailed look at how the WP Code plugin works.

Installation and setup

  • Go to Plugins > Add New and search for WP Code.

  • Once found, Install and Activate it.

Once activated, WP Code will add a new menu item to your WordPress dashboard. From here, you can access the plugin’s settings page.

Adding code snippets

The main functionality of WP Code is to provide an easy interface where you can add code snippets without touching the theme’s PHP files. This is especially useful for adding analytics tracking codes, custom CSS, meta tags, or JavaScript libraries. Here’s how you use it:

  • Open the WP Code settings from your WordPress dashboard. You will typically find separate sections for adding code to the header, body, and footer.

  • Header code: Code placed here will be added to the <head> section of your WordPress site. Copy and paste in the code written down below.

  • Saving changes: After adding your code snippets in the appropriate boxes, you save the changes. The plugin then automatically inserts these snippets into your site’s HTML output in their specified locations on every page load.

<script src="https://a.sourcegeek.com/tracking.js" defer></script>

Method 2: Manually edit theme files

If you’re comfortable with HTML/PHP and WordPress theme structure, you might prefer to manually insert JavaScript code into your theme files.

Steps:

  • From your WordPress dashboard, go to Appearance > Theme File Editor.

  • Locate the header.php file from the list on the right.

  • Insert the JavaScript code below between <script> tags at the appropriate location in the file.

  • Save your changes.

<script src="https://a.sourcegeek.com/tracking.js" defer></script>

Method 3: Utilizing functions.php

The functions.php file in your WordPress theme allows you to add custom functions, including enqueuing JavaScript files, which is a WordPress-standard method.

Using wp_enqueue_script(): This function ensures your scripts don’t conflict with others and can be combined with WordPress hooks for precise placement.

Steps:

  • Access the functions.php file via Appearance > Theme Editor in WordPress.

  • Add the script below

  • Make sure to save the changes.

add_action('wp_enqueue_scripts','add_sourcegeek_script');

function add_sourcegeek_script() {
wp_enqueue_script( 'sourcegeek-script', '//a.sourcegeek.com/tracking.js',false);
}

If you are not able to find these files in your admin, you might want to access them using FTP or the File Manager of your hosting provider.

Did this answer your question?