# How Google Analytics Is Integrated into the Resume GitHub Pages Application

> Learn how Google Analytics integrates into the Resume GitHub Pages app using a conditional JavaScript loader in js/githubresume.js for tracking.

- Repository: [GitHub resume generator/resume.github.com](https://github.com/resume/resume.github.com)
- Tags: how-to-guide
- Published: 2026-03-04

---

**The Resume GitHub Pages application embeds Google Analytics through a conditional JavaScript loader in [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js) that uses the legacy `_gaq` asynchronous syntax to initialize tracking only when a valid tracker ID is present.**

The resume/resume.github.com repository generates dynamic résumés from GitHub profiles using client-side JavaScript. Understanding how Google Analytics is integrated into this static site architecture reveals a lightweight, configurable tracking implementation that relies on the classic [`ga.js`](https://github.com/resume/resume.github.com/blob/main/ga.js) library rather than modern gtag.js or Google Analytics 4.

## Google Analytics Integration Architecture

### Tracker ID Configuration in [`githubresume.js`](https://github.com/resume/resume.github.com/blob/main/githubresume.js)

The integration centers on a single variable definition at the top of [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js). Line 3 declares the property ID that connects the application to your Google Analytics account:

```javascript
var trackerId = 'UA-21222559-1';

```

This string corresponds to the **Universal Analytics** tracking ID format. The variable acts as a configuration switch—when populated with a valid ID, it triggers the analytics initialization sequence; when empty or undefined, the tracking code remains dormant.

### Conditional Loading Logic

Rather than loading analytics unconditionally, the application wraps the Google Analytics bootstrap code in a truthiness check. Starting at approximately line 60 in [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js), the implementation verifies `trackerId` before executing:

```javascript
if (trackerId) {
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', trackerId]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www')
             + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
  })();
}

```

This pattern utilizes the legacy **`_gaq`** queue system from Google Analytics Classic. The code creates an asynchronous script element pointing to [`ga.js`](https://github.com/resume/resume.github.com/blob/main/ga.js)—the predecessor to the current [`analytics.js`](https://github.com/resume/resume.github.com/blob/main/analytics.js) and [`gtag.js`](https://github.com/resume/resume.github.com/blob/main/gtag.js) libraries. The conditional wrapper ensures that developers running local copies or forks without analytics credentials will not generate tracking errors or unnecessary network requests.

### Script Initialization in [`index.html`](https://github.com/resume/resume.github.com/blob/main/index.html)

The analytics functionality enters the application through a single script inclusion in the main HTML entry point. Line 17 of [`index.html`](https://github.com/resume/resume.github.com/blob/main/index.html) loads the JavaScript file containing the tracking logic:

```html
<script type="text/javascript" src="js/githubresume.js"></script>

```

Because the Google Analytics code lives entirely within [`githubresume.js`](https://github.com/resume/resume.github.com/blob/main/githubresume.js), the HTML remains clean of inline tracking snippets. This separation of concerns allows the analytics implementation to evolve independently of the markup structure.

## Customizing Google Analytics in the Application

### Changing the Tracker ID

To associate the résumé generator with your own Google Analytics property, modify the `trackerId` variable at the beginning of [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js):

```javascript
// Replace with your Universal Analytics ID
var trackerId = 'UA-12345678-9';

```

After updating this value and redeploying, the application will begin sending pageview data to your specified property.

### Disabling Analytics Completely

For local development environments or privacy-conscious deployments, disable tracking by setting the variable to an empty string or null:

```javascript
var trackerId = '';

```

With this configuration, the conditional check `if (trackerId)` evaluates to false, preventing the creation of the `_gaq` array and the injection of the [`ga.js`](https://github.com/resume/resume.github.com/blob/main/ga.js) script.

### Tracking Custom Events

The legacy `_gaq` API supports event tracking for user interactions beyond pageviews. To instrument specific actions—such as downloading a PDF or sharing a résumé—push event commands to the queue:

```javascript
if (window._gaq) {
  _gaq.push(['_trackEvent', 'Resume', 'Download', 'PDF']);
}

```

This snippet checks for the existence of the global `_gaq` object to avoid errors if analytics are disabled, then records an event in category "Resume", action "Download", and label "PDF".

## Summary

- The Resume GitHub Pages application implements Google Analytics through a conditional loader in [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js) using the legacy [`ga.js`](https://github.com/resume/resume.github.com/blob/main/ga.js) library.
- Tracking activates only when the `trackerId` variable contains a valid Universal Analytics ID, allowing easy disabling for development.
- The integration uses the `_gaq` asynchronous queue pattern to set the account and track pageviews without blocking page rendering.
- Custom events can be added by pushing to the `_gaq` array after verifying the object exists.

## Frequently Asked Questions

### Where is the Google Analytics tracker ID defined?

The tracker ID is defined as a JavaScript variable named `trackerId` at line 3 of [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js). By default it contains `'UA-21222559-1'`, but you can replace this string with your own Universal Analytics property ID.

### Can I use Google Analytics 4 with this integration?

The current implementation uses the legacy [`ga.js`](https://github.com/resume/resume.github.com/blob/main/ga.js) library and the `_gaq` API, which corresponds to Universal Analytics (UA). To use Google Analytics 4 (GA4), you would need to replace the entire conditional block in [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js) with the modern [`gtag.js`](https://github.com/resume/resume.github.com/blob/main/gtag.js) initialization code and update the tracking ID format to a GA4 measurement ID.

### How do I disable tracking for local development?

Set the `trackerId` variable to an empty string or `null` at the top of [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js). When this variable is falsy, the conditional check prevents the `_gaq` array initialization and the [`ga.js`](https://github.com/resume/resume.github.com/blob/main/ga.js) script injection, effectively disabling all analytics tracking without modifying the rest of the application logic.

### What file loads the Google Analytics script?

The Google Analytics script is loaded by [`js/githubresume.js`](https://github.com/resume/resume.github.com/blob/main/js/githubresume.js), which is included in the main HTML entry point [`index.html`](https://github.com/resume/resume.github.com/blob/main/index.html) via a standard script tag on line 17. The analytics code itself resides within the JavaScript file rather than being embedded directly in the HTML markup.