How To Event Stream Data From Your Nuxt.Js App Using RudderStack
Tags: nuxt, eventstream, dataanalytics, cdp
Published: 2021-12-22 09:53:03

[RudderStack](https://rudderstack.com/) is an open-source Customer Data Pipeline that enables you to track events from your web, mobile, and server-side sources and send them to your whole 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 is a guide that will help you to easily integrate your [Nuxt.js](https://nuxtjs.org/) app with RudderStack using our [JavaScript SDK](https://github.com/rudderlabs/rudder-sdk-js). This integration allows you to track real-time user events and send them to your preferred destinations.

You can instrument event streams on your Nuxt.js app using the following three key steps:

1.  Integrate Nuxt.js app 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 Nuxt.js app and verify the event stream

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

We assume you have installed and set up your Nuxt.js app. If you haven't, visit the [official Nuxt.js documentation](https://nuxtjs.org/docs/2.x/get-started/installation/) to get started.

Step 1: Integrating Your Nuxt.Js App With RudderStack JavaScript SDK
--------------------------------------------------------------------

### Creating A Source In RudderStack

First, you will need to set up a JavaScript source in your RudderStack dashboard that you will use to track events from your Nuxt.js app. 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 successful login, you should see the following dashboard:

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

3\. Make a note of the Data Plane URL. You will need this URL to integrate your Nuxt.js app with RudderStack.

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

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

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

5\. Assign a name to your Source and click on Next.

![](https://cdn.sanity.io/images/mwovquhr/production/d0e2ef39955da5294c0984f3bba7f429c52dd18c-630x195.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 Nuxt.js app.

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

### Integrating Your Nuxt.Js App With RudderStack

Integrate RudderStack with your Nuxt.js app and set up the tracking code following steps given below:

Modify the `nuxt.config.js` file in your app's folder to include the following script:

`gist:Veenap/3626e9bac218dde5a66fc2583eb31bd1`

![](https://cdn.sanity.io/images/mwovquhr/production/0087b9aa1e78b4493063269ba9253ff8df9c9cd4-1318x951.png)

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

Step 2: Creating A Destination Tool In RudderStack For Routing Your Nuxt.Js App 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 tutorial, we will route the Nuxt.js app 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 for this tutorial.

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

5\. In the Connection Settings, 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\. Voila! 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 In RudderStack For Your Nuxt.Js App Events
---------------------------------------------------------------------------------------------

mportant: *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* [*docs*](https://docs.rudderstack.com/data-warehouse-integrations) *to get detailed and step-by-step instructions on how to do it for your preferred data warehouse.*

We will set up a [Google BigQuery warehouse destination](https://rudderstack.com/integration/bigquery/on) for this tutorial to route all the events from our Nuxt.js app. 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 these steps:

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

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

2\. Add 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 Nuxt.js app events. Then, click on Next.

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

4\. Specify the Connection Credentials. Enter the 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. Find more information on how to do this in 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 Nuxt.Js App 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 Nuxt.js 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 Nuxt.js app.

2\. To deploy the app, run `npm run dev` command, as shown:

![](https://cdn.sanity.io/images/mwovquhr/production/44544a627fb9d27f96e100470809ebe5928ef0da-1232x777.png)

3\. Open your Nuxt.js app by visiting the URL [http://localhost:3000](http://localhost:3000/) on your browser.

![](https://cdn.sanity.io/images/mwovquhr/production/d2b35ef623efbb081ad36bdf0bd4437a928c2e20-1545x944.png)

4\. To verify if `rudder-analytics.js` (RudderStack's JavaScript SDK) has loaded correctly, 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/60eec290ea67ce500b5705ce5226cb7fcc030449-680x623.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:

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.

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

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

![](https://cdn.sanity.io/images/mwovquhr/production/c29ed69dbb0935d032f269528f9e7e1d02ded4e8-1600x828.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/c97b3127233624468b8655d287efcc380b5236ad-1600x505.png)

We can see one active user on our Nuxt.js app, 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
-------

Monitoring in-app data is crucial to understand the real performance of your app and the user behavior. The insights you gain from this monitoring enable you to update your app to your customers' needs. Continuously adapting your app to maintain likeability is an important trait of a successful app. RudderStack helps you achieve this securely.

In this tutorial, we learned how to instrument real-time event data on your Nuxt.js App using RudderStack. We integrated the Nuxt.js app with RudderStack JS SDK and learned how to set up the tracking code. We also set up 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)