Skip to main content
Signals implementation
Real-time personalization

Set up Signals for real-time calculation

Set up Signals to calculate attributes in real time, using Snowplow Console or the Signals Python SDK.

Progress0%

Retrieve calculated attributes using the Signals Python SDK

For a real use case, you'll want to consume calculated attributes in your applications. Read more about this in the Signals documentation.

For this tutorial, we've provided a Jupyter notebook so you can quickly explore attribute retrieval using the Signals Python SDK.

Finding your current session ID#

In your real application code, you can access the current session ID and use it to retrieve the relevant attribute values. The attributes are being calculated in real time, in session. Read about how to access IDs such as domain_sessionid in your web application in the JavaScript tracker documentation.

To test this out, use the Snowplow Inspector browser extension to find out your current session ID on your web application. Click around and generate some page view events. Then find your Domain Session ID in the Inspector.

Screenshot showing the session ID in the Snowplow Inspector

Connecting to Signals#

Install the Signals Python SDK into the notebook, and connect to Signals.

  1. Go to Signals > Overview in Snowplow Console to find your Signals credentials
  2. Add them to the notebook secrets:

Screenshot showing how to add secrets

  1. Install the SDK:
python
%pip install snowplow-signals
  1. Connect to Signals:
python
from snowplow_signals import Signals
from google.colab import userdata

sp_signals = Signals(
api_url=userdata.get('SP_API_URL'),
api_key=userdata.get('SP_API_KEY'),
api_key_id=userdata.get('SP_API_KEY_ID'),
org_id=userdata.get('SP_ORG_ID'),
)

Retrieving your session attributes#

Use your current session ID to retrieve the attributes that Signals has just calculated about your session.

python
response = sp_signals.get_service_attributes(
name="quickstart_service",
attribute_key="domain_sessionid",
identifier="472f97c1-eec1-45fe-b081-3ff695c30415", # UPDATE THIS
)

df=response.to_dataframe()
df

The result should look something like this:

domain_sessionidpage_view_countmost_recent_browserfirst_referrer
0472f97c1-eec1-45fe-b081-3ff695c304152.0Firefoxsnowplow.io

Retrieving single attributes#

To retrieve individual attributes rather than using a service, use the get_group_attributes() method.

python
response = sp_signals.get_group_attributes(
name="quickstart_group",
version=1,
attributes=["page_view_count"],
attribute_key="domain_sessionid",
identifiers=["472f97c1-eec1-45fe-b081-3ff695c30415"]
)

df=response.to_dataframe()
df