How To Event Stream Data From Your Jekyll Site To Google Analytics Using RudderStack
Tags: eventstream, jekyll, javascript, analytics
Published: 2021-12-28 10:48:57

[RudderStack](https://rudderstack.com/) is an open-source Customer Data Pipeline that helps you track your customer events from your web, mobile, and server-side sources and sends them to your entire customer data stack in real-time. We have also open-sourced our primary GitHub repository - [rudder-server](https://github.com/rudderlabs/rudder-server).

This blog will help you quickly integrate your Jekyll site with RudderStack using our [JavaScript SDK](https://github.com/rudderlabs/rudder-sdk-js) and get started with tracking real-time user events and send them to your preferred destinations.

Instrument event streams on your Jekyll site by following three simple steps:

1.  Integrate the Jekyll Site with RudderStack JavaScript SDK and set up the tracking code
2.  Set up a tool or warehouse destination in RudderStack to route all the event data in real-time
3.  Deploy your Jekyll site and verify the event stream

Pre-Requisites
--------------

Before getting started, you need to ensure your Jekyll site is installed and set up. If you haven't done it yet, visit the [official Jekyll installation doc](https://jekyllrb.com/docs/installation/) to get started.

Step 1: Integrating Your Jekyll Site With RudderStack JavaScript SDK
--------------------------------------------------------------------

### Creating A Source In RudderStack

You need to set up a JavaScript source in your RudderStack dashboard that will track events from your Jekyll site. Follow these steps to set up the source:

1.  Log into your [RudderStack dashboard](https://app.rudderstack.com/). If you're new to RudderStack, [sign up here](https://app.rudderlabs.com/signup?type=freetrial).
2.  On login, you should see the following dashboard:

![](https://cdn.sanity.io/images/mwovquhr/production/d103d2c6452dcee6f44c27ee8087e864cdbb84a2-630x319.png)

3\. Note down the Data Plane URL. You will need this URL to integrate your Jekyll site with RudderStack.

![](https://cdn.sanity.io/images/mwovquhr/production/654cffa6fa2c334832f4281927f69d3d6ce49fd7-518x194.png)

4\. Create a Source by clicking on the Add Source option. You can also click on the Directory option in the left nav bar and select Event Streams under Sources, as shown. Next, select JavaScript.

![](https://cdn.sanity.io/images/mwovquhr/production/e906f26d6b0132d870057e3700cff46b4f9a107c-630x327.png)

5\. Add a name for JavaScript Source and click on Next.

![](https://cdn.sanity.io/images/mwovquhr/production/ae4a58bd7965bf9088d15e2b85233639fd7fbc67-630x290.png)

6\. Your JavaScript source is now configured and ready to track events. Note the Write Key associated with this source. You will need it to set up the RudderStack integration with your Jekyll site.

![](https://cdn.sanity.io/images/mwovquhr/production/00105d7adc808d9f3f0323050edbcb516d7703ae-630x149.png)

### Integrating Your Jekyll Site With RudderStack

Integrate RudderStack JavaScript code with your Jekyll Site and set up the tracking code following steps given below:

1.  Jekyll has an extensive theme system that helps customize your site's presentation. Minima is Jekyll's default theme. You can check your default theme using the following command:

```
bundle info --path minima
```

The following command opens an explorer window showing the theme files and directories.

```
`open $(bundle info --path minima)`
```

2\. Next, create** [`rudder.html`](https://github.com/rudderlabs/rudder-analytics-jekyll/blob/main/rudder.html) inside the `_includes` folder in the `minima` theme folder (*Location: C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems*) to include the following script:

```
<script>  rudderanalytics = window.rudderanalytics = [];  var methods = [    "load",    "page",    "track",    "identify",    "alias",    "group",    "ready",    "reset",    "setAnonymousId",    "getAnonymousId",  ];  for (var i = 0; i < methods.length; i++) {    var method = methods[i];    rudderanalytics[method] = (function (methodName) {      return function () {        rudderanalytics.push(          [methodName].concat(Array.prototype.slice.call(arguments))        );      };    })(method);  }  rudderanalytics.load(    "YOUR_WRITE_KEY",    "DTA_PLANE_URL"  );  rudderanalytics.ready(function () {    console.log("Application is ready with JS");  });  rudderanalytics.track("Simple track call1");</script><script src="https://cdn.rudderlabs.com/v1/rudder-analytics.min.js"></script>
```

Create rudder.html file

Note: If you have installed any other theme (other than minima), you will have to make changes to the files of that theme.

```
{%- include rudder.html -%}
```

Now go to `_includes/[head.html](https://github.com/rudderlabs/rudder-analytics-jekyll/blob/main/head.html)` of your theme folder and add the command given below:

Important: You can refer to our sample Jekyll site present in our [*RudderStack Jekyll site repository*](https://github.com/rudderlabs/rudder-analytics-jekyll) [for more information on modifying these files.](https://github.com/rudderlabs/rudder-analytics-jekyll)

Step 2: Creating A Destination Tool In RudderStack For Routing Your Jekyll Site Events
--------------------------------------------------------------------------------------

RudderStack supports over [80 third-party tools](https://rudderstack.com/integration/) and platforms to which you can securely send your tracked events. In this section, we will route the Jekyll Site events to [Google Analytics](https://docs.rudderstack.com/destinations/google-analytics-ga). To add Google Analytics as a destination in RudderStack, follow the steps given below:

1.  In the left navigation bar of your RudderStack dashboard, click on Destinations and select Add Destination. Since we have already configured a source, you can simply click on the source and click on the Add Destination option, as shown:

Note: You can use Connect Destinations option if you have already configured a destination in RudderStack and want to send your event data to that platform.

![](https://cdn.sanity.io/images/mwovquhr/production/bb027d1e3ad7665d7f7bdf68bd3df7da833daae8-630x316.png)

2\. Next, choose Google Analytics as your Destination.

![](https://cdn.sanity.io/images/mwovquhr/production/dee0813b1679e76a5fb623df69bfd21dafd7e804-630x316.png)

3\. Add a name to your destination and click on Next, as shown:

![](https://cdn.sanity.io/images/mwovquhr/production/638e3e2ef556357ec424b5ec30d3943504fb9827-630x317.png)

4\. Now, connect the JavaScript source that we have already configured in Step 1.

![](https://cdn.sanity.io/images/mwovquhr/production/22da8027cb80f55cc4c81cc56e8e49aa30996b89-630x317.png)

5\. On the Connection Settings page, configure your Google Analytics destination with your Google Analytics Tracking ID and other optional settings, as shown below. Then, click on Next.

![](https://cdn.sanity.io/images/mwovquhr/production/53654b0aee376a392973f2b0f7c55b66a2749272-630x334.png)

6\. You can also transform your events before sending them to Google Analytics. For more information on this feature, check out our [documentation](https://docs.rudderstack.com/adding-a-new-user-transformation-in-rudderstack) on User Transformations.

7\. Great job! Google Analytics is now configured as a destination. You should now see the following source-destination connection in your dashboard:

![](https://cdn.sanity.io/images/mwovquhr/production/6cd115d36f1604e2a795e207d55fd4c9f2f96f3b-630x244.png)

(Alternate) Step 2: Create A Warehouse Destination For Your Jekyll Site Events
------------------------------------------------------------------------------

Important: Before you configure a data warehouse as a destination in RudderStack, you will need to set up a new project in your data warehouse. Also, you need to create a new RudderStack user role with the relevant permissions.

Follow our [documentation](https://docs.rudderstack.com/data-warehouse-integrations) to get step-by-step instructions on how to do it for your preferred data warehouse.

We will configure a [Google BigQuery warehouse destination](https://rudderstack.com/integration/bigquery/on) for this tutorial to route all the events from our Jekyll Site. You can set up a BigQuery project with the required permissions for the service account by following [our documentation](https://docs.rudderstack.com/data-warehouse-integrations/google-bigquery).

Once you have set up the project and assigned the required user permissions, follow the instructions given below:

1\. From the Destinations Directory, select Google BigQuery:

![](https://cdn.sanity.io/images/mwovquhr/production/d901af95b4b3a046ea62b4e7354473f7a4932deb-630x328.png)

2\. Assign a name to your Destination and click on Next.

![](https://cdn.sanity.io/images/mwovquhr/production/fdf892d0f37e4c6c9ec4c31bd48253b26a6da774-630x290.png)

3\. Connect to JavaScript source from which we will track our Jekyll Site events. Then, click on Next.

![](https://cdn.sanity.io/images/mwovquhr/production/ae4a58bd7965bf9088d15e2b85233639fd7fbc67-630x290.png)

4\. Specify Connection Credentials. Add BigQuery Project ID and the Staging Bucket Name. You can refer to these [instructions](https://docs.rudderstack.com/data-warehouse-integrations/google-bigquery#setting-up-google-bigquery) to get this information.

![](https://cdn.sanity.io/images/mwovquhr/production/e92473af23c60ee47bdaef090e8131796594864c-357x834.png)

5\. Lastly, copy the contents of the private JSON file. For more information on how to do this, refer to our [documentation](https://docs.rudderstack.com/data-warehouse-integrations/google-bigquery#setting-up-the-service-account-for-rudderstack).

That's all! You have successfully set up BigQuery as a warehouse destination in RudderStack.

Step 3: Deploying Your Jekyll Site And Verifying The Event Stream
-----------------------------------------------------------------

We have successfully configured our event source and destination. Let's verify if our event stream works correctly. To do so, let's deploy our Jekyll Site application and test if the events are tracked by the JavaScript source and delivered to our Google Analytics destination.

Follow these steps to find:

1\. On your Terminal or cmd, navigate to the folder containing your Jekyll Site.

2\. To deploy the app, run `bundle exec jekyll serve`command, as shown:

![](https://cdn.sanity.io/images/mwovquhr/production/5d253da961da2ed15597e14789bb728fa85ea936-825x499.png)

3\. Open your Jekyll site by visiting the server address mentioned in the cmd or [http://localhost:4000](http://127.0.0.1:4000/) on your browser.

![](https://cdn.sanity.io/images/mwovquhr/production/854c199b0c702b2ee3a44c5eb7a24ddc8b6dbf01-1713x975.png)

4\. Next, verify if `rudder-analytics.js` (RudderStack's JavaScript SDK) has loaded correctly. To do this, go to your browser's Developer tools and navigate to the Network tab. The following screenshot highlights this option for Google Chrome:

![](https://cdn.sanity.io/images/mwovquhr/production/73b3c037efd60d33a2513faea74ae3889f2b28e9-705x606.png)

5\. Check if RudderStack can track the different pageviews and clicks by clicking on the Live Events tab of your JavaScript source on the RudderStack dashboard page:

![](https://cdn.sanity.io/images/mwovquhr/production/1859e5a94847c323bd450e19b15fcb46b8973bee-630x272.jpg)

Note: *After deploying your app, there can sometimes be a lag before events start sending and are visible in your dashboard and destination. Don't worry. All events are captured and sent; just be aware that they can take a few minutes to show up.*

6\. Brilliant! RudderStack has successfully tracked and captured the events:

![](https://cdn.sanity.io/images/mwovquhr/production/72e3908d2f73bc0ff6928d5571bb6c1e02aee8aa-1602x947.png)

7\. Next, let's check if the events are sent to our Google Analytics destination. Go to your Google Analytics dashboard and navigate to the Realtime - Events option.

![](https://cdn.sanity.io/images/mwovquhr/production/695d5832a4f543f29e41411f495a8f6936536a41-1842x659.png)

As you can see, we have one active user on our Jekyll site, and the track event is visible too. This shows that the event has been tracked and delivered successfully. Similarly, you should also receive the event in your Google BigQuery warehouse.

Summary
-------

Website analytics help companies gain a macroscopic understanding of how users interact with multiple features on your site. This ensures that the website is up and running and performs in the best way possible, and results in a better end-user experience. RudderStack helps you achieve this securely.

In this post, we learned how to instrument real-time event data on your Jekyll site using RudderStack. We integrated the Jekyll site with RudderStack JS SDK and set up the tracking code. We also integrated Google Analytics as a destination in RudderStack to route all event streams in real-time and also verify successful delivery of the event streams.

### Sign Up For Free And Start Sending Data

Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app. [Get Started](https://app.rudderlabs.com/signup?type=freetrial)