RudderStackĀ 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.
This blog will help you quickly integrate your Jekyll site with RudderStack using ourĀ JavaScript SDKĀ 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:
- Integrate the Jekyll Site with RudderStack JavaScript SDK and set up the tracking code
- Set up a tool or warehouse destination in RudderStack to route all the event data in real-time
- 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Ā 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:
- Log into yourĀ RudderStack dashboard. If you're new to RudderStack,Ā sign up here.
- On login, you should see the following dashboard:
3. Note down theĀ Data Plane URL. You will need this URL to integrate your Jekyll site with RudderStack.
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.
5. Add a name for JavaScript Source and click onĀ Next.
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.
Integrating Your Jekyll Site With RudderStack
Integrate RudderStack JavaScript code with your Jekyll Site and set up the tracking code following steps given below:
- 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
Ā 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Ā for more information on modifying these files.
Step 2: Creating A Destination Tool In RudderStack For Routing Your Jekyll Site Events
RudderStack supports overĀ 80 third-party toolsĀ and platforms to which you can securely send your tracked events. In this section, we will route the Jekyll Site events toĀ Google Analytics. To add Google Analytics as a destination in RudderStack, follow the steps given below:
- 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.
2. Next, chooseĀ Google AnalyticsĀ as your Destination.
3. Add a name to your destination and click onĀ Next, as shown:
4. Now, connect theĀ JavaScriptĀ source that we have already configured in Step 1.
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.
6. You can also transform your events before sending them to Google Analytics. For more information on this feature, check out ourĀ documentationĀ 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:
(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Ā to get step-by-step instructions on how to do it for your preferred data warehouse.
We will configure aĀ Google BigQuery warehouse destinationĀ 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.
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:
2. Assign a name to your Destination and click onĀ Next.
3. Connect toĀ JavaScript sourceĀ from which we will track our Jekyll Site events. Then, click on Next.
4. SpecifyĀ Connection Credentials. AddĀ BigQuery Project IDĀ and theĀ Staging Bucket Name. You can refer to theseĀ instructionsĀ to get this information.
5. Lastly, copy the contents of the privateĀ JSON file. For more information on how to do this, refer to ourĀ documentation.
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:
3. Open your Jekyll site by visiting the server address mentioned in the cmd orĀ http://localhost:4000Ā on your browser.
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:
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:
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:
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.
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
Top comments (0)