Before you begin

  1. Set up BigQuery and connect it to SegmentStream.
  2. Make sure that SegmentStream JavaScript snippet is deployed on all website pages.

Real-time event data collection

  1. Go to your website and visit a few pages.

  2. Make sure that data is collected in the Chrome browser console: How data is collected in Chrome browser console

  3. Go to the Google Cloud Platform and check whether the new hits_YYYYMMDD table was created in you Google BigQuery Console: Image shows how hits table is created in Google BigQuery Note, that there are actually 2 hits tables were created: hits and hits_YYYYMMDD. First one is just a template that keeps the schema and used to create daily hits tables.

  4. Click on the hits_YYYYMMDD table and then on the “Query Table” button: Image shows how to query BigQuery table

  5. Run the following query in the Query editor:
    SELECT hitId,, context FROM `<FULL_TABLE_NAME>`

    Note, that you should use proper full table name which is automatically filled once you click “Query Table” button.

  6. If everything was set up properly you will see results about pageviews from your website: Image shows query results about page views

Great! Now you’ve set up a real-time collection of all page views on your website.

Advanced events tracking

Let’s imagine you have an e-commerce website and would like to track all user transactions. Of cause, this should be properly set up by developers but for the purpose of this quick guide let’s send a “fake” transaction.

  1. Open Chome browser console and copy-paste the following code:{
      category: 'Ecommerce',
      name: 'Completed Transaction',
      transaction: {
     orderId: "QA-123456",
     currency: "USD",
     subtotal: 310,
     shippingCost: 10,
     shippingMethod: "Delivery",
     total: 320,
     lineItems: [
         product: {
           id: "1234567890",
           name: "Timberland shoes",
           manufacturer: "Timberland",
           category: ["Shoes","Boots"],
           currency: "USD",
           unitPrice: 150,
           unitSalePrice: 110,
           skuCode: "TBL6065RW",
         quantity: 2,
         subtotal: 220
         product: {
           id: "54563454",
           name: "Nike shoes",
           manufacturer: "Nike",
           category: ["Shoes","Sport"],
           currency: "USD",
           unitPrice: 120,
           unitSalePrice: 90,
           skuCode: "TBL6065ZX",
         quantity: 1,
         subtotal: 90

    Image shows how to track transactions using Google Chrome's console

  2. Go back to the Google BigQuery console, click on hits_YYYYMMDD table and again click on “Query Table” button. At this time let’s select all tracked transactions using the following query:
    SELECT event.transaction
    WHERE = "Completed Transaction"

    Again, don’t forget to replace <FULL_TABLE_NAME> with your proper full table name.

  3. You should observe similar results:
  4. Image shows query results about transactions

Behavioral events tracking

Finally, let’s try to set up tracking of a behavioral event, such as click.

  1. Firstly, you need to figure out the CSS selector of the element you would like to track. It can be easily done using Google Chrome’s console. In the example below, the CSS selector of the “Show more products” button is the .moreProducts because the element has a CSS class morePoducts. Image shows how to find a CSS selector in Google Chrome console If you don’t know how to figure out a CSS selector of a specific element - ask your frontend developers.

  2. Now, go to the SegmentStream admin panel Events section and click Add button to add a new event as shown on the screen below: Image shows how to add a new click event in the admin panel

  3. Enter the event name.

  4. Select Click as a trigger.

  5. Enter the proper CSS selector.

  6. Add event handler:
    return {
      category: 'Behaviour'
      name: 'Clicked Button', // use your event name
      label: 'some label'
  7. Click Save to save the event.

  8. Click Publish to publish a new container (up to several minutes might be required for the changes to be propagated to the CDN server).

  9. Reload your website’s page, go back to the Google Chrome’s browser console and check that your click handler is working properly: Image shows how to check whether click handler is working using Google Chrome console

  10. Go to the Google BigQuery console and query information about your click event:

    Don’t forget to replace <FULL_TABLE_NAME> and <EVENT_NAME> with proper values.

Now you know how to setup basic events tracking and in SegmentStream and send this event to the Google BigQuery integration.

Similarly, you can connect any other integration, such as Google Analytics or Facebook. SegmentStream will automatically transform events in a proper format which each of these systems understand.

For example, this is how click event from the previous step will look like in the Google Analytics interface: Image shows how click event looks like in Google Analytics

What’s next

This document was last updated on June 11, 2019. If you notice any gaps, outdated information or simply want to leave some feedback to help us improve our documentation, please let us know!