Improve search results using client events (v3)

Cloud Talent Solution is a service that brings machine learning to your job search experience, returning high quality results to job seekers far beyond the limitations of typical keyword-based methods. Right out of the box, CTS applies relevance models and job/skill ontologies to your job details. You can improve the results returned to job seekers by recording client events based on the activity of the job seeker.

There are two methods for leveraging this feature, both outlined in this quickstart. We recommend that you use the createClientEventRequest API method, which bypasses the authentication challenges of sending messages to Cloud Talent Solution using Cloud Pub/Sub and provides a clean set of APIs to implement the analytics framework.

You'll begin publishing client event data by the end of the tutorial.

When a job seeker performs a specific action, you can use the API to record that action. For example, the job seeker or other entity interacting with the service has had a job (or a list of jobs) rendered in their view, such as in a list of search results in a compressed or clipped format. In this case you can send an IMPRESSION event to Cloud Talent Solution to provide the context of the search results and what a job seeker can see. Further, when the job seeker clicks on a job result to view the full job description, you can send a VIEW event to register the interest of this job seeker in this position.

Usage

The following example illustrates how to send a message to Cloud Talent Solution using the API. The job seeker or other entity interacting with the service has had a job (or a list of jobs) rendered in their view, such as in a list of search results in a compressed or clipped format. This event is typically associated with the viewing of a jobs list on a single page by a job seeker.

Java

For more on installing and creating a Cloud Talent Solution client, refer to Cloud Talent Solution Client Libraries.


public static void createClientEvent(String eventId, String requestId,
    List<String> relatedJobNames)
    throws IOException {
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
  String date = dateFormat.format(new Date());

  ClientEvent clientEventToBeCreated = new ClientEvent()
      .setCreateTime(date)
      .setEventId(eventId)
      .setParentEventId("NULL")
      .setJobEvent(
          new JobEvent().setJobs(relatedJobNames)
              .setType("VIEW"))
      .setRequestId(requestId);
  CreateClientEventRequest createClientEventRequest = new CreateClientEventRequest()
      .setClientEvent(clientEventToBeCreated);

  ClientEvent returnedEvent = talentSolutionClient.projects().clientEvents()
      .create(DEFAULT_PROJECT_ID, createClientEventRequest).execute();
  System.out.println(returnedEvent);
}

Python

For more on installing and creating a Cloud Talent Solution client, refer to Cloud Talent Solution Client Libraries.

def create_client_event(client_service, event_id, request_id, related_job_names):
    now = datetime.datetime.now()
    date = now.strftime('%Y-%m-%dT%H:%M:%SZ')

    client_event_to_be_created = {
        'create_time': date,
        'event_id': event_id,
        'parent_event_id': 'NULL',
        'job_event': {
            'jobs': related_job_names,
            'type': 'VIEW'
        },
        'request_id': request_id
    }
    request = {
        'client_event': client_event_to_be_created
    }
    response = client_service.projects().clientEvents().create(
        parent=parent, body=request).execute()
    print(response)

Please visit Event Types for a full listing of available event types.

Record client event requests using Cloud Pub/Sub

Requirements

In order to publish pubsub messages it is required that you publish messages ONLY to the project p-jobs and the topic cloud-jobs-events.

Any pubsub message that does not contain a requestId is dropped.

Prerequisites

You have:

This tutorial covers the integration instructions to create a publisher client, publish client events through Cloud Pub/Sub, and clean up. We demonstrate the integration by stepping through a Cloud Talent Solution application using Java code, that focuses on explaining how to make calls to Cloud Talent Solution, rather than explaining the Java client libraries.

Publish client event data to Cloud Talent Solution

This section walks you through publishing client event data to Cloud Talent Solution, which can be used to improve relevance for your specific business and job seeker needs.

Follow the Google Cloud Pub/Sub Publisher Guide to publish messages to Cloud Talent Solution.

Check that the actual messages sent follow the pattern as described below.

Sample messages

IMPRESSION event

JSON

    {
      "eventId": "857523730h91wrgkih9qpl12z8bf",
      "eventType": "IMPRESSION",
      "requestId": "8d2bdd5d-1361-42a5-a0fd-bd2b58b7d8fb:APAb7ISd4Sc5faibw2V5hTU/OoC2WAW5AA==",
      "relatedJobNames": [
        "jobs/4000000000",
        "jobs/4000000001"
      ],
      "eventTimestampMillis": 1518200614309,
    }
    

VIEW event

JSON

    {
      "eventId": "9q9wa69qgfx1q1xzwn3zo25z",
      "eventType": "VIEW",
      "requestId": "248pla4w-8wpl-87rt-15rt-430ue8u541m8",
      "relatedJobNames": [
        "jobs/8000000000",
        "jobs/8000000001"
      ],
      "eventTimestampMillis": 1518200617426,
    }
    

Verify implementation using the Cloud Talent Solution management tools

Cloud Talent Solution provides users of the API with tools to verify your implementation by providing you with self service tools. Learn more about the self service tools.