# How to test the relevance CookieCollector

**URL:** <https://community.bloomreach.com/t/how-to-test-the-relevance-cookiecollector/4504>\
**Category:** Uncategorized\
**Created:** [September 12, 2024, 1:49pm UTC](https://community.bloomreach.com/t/how-to-test-the-relevance-cookiecollector/4504 "2024-09-12T13:49:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mijnisha](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Mijnisha](https://community.bloomreach.com/u/Mijnisha)\
**Post date:** [September 12, 2024, 1:49pm UTC](https://community.bloomreach.com/t/how-to-test-the-relevance-cookiecollector/4504/1 "2024-09-12T13:49:49Z")

</div>

Hello all,  
I have configure the relevance cookiecollector. But this collector does not come with a ui or out of the box charactaristic. So I was wondering, how can I test/access this cookiecollector and the data it collected.

I am also trying to use the Expression Inference rule engine. Can I use the data of this collector there ?

---

<div class="post-metadata">

**Author:** ![Rajesh\_Sailada](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/rajesh_sailada/32/1374_2.png) [@Rajesh\_Sailada](https://community.bloomreach.com/u/Rajesh_Sailada)\
**Post date:** [December 20, 2024, 3:02pm UTC](https://community.bloomreach.com/t/how-to-test-the-relevance-cookiecollector/4504/2 "2024-12-20T15:02:12Z")

</div>

Hi @Mijnisha ,

To test and access the data collected by the relevance `cookiecollector`, you can follow these steps:

1. Accessing the Collected Data:

- The data collected by the `cookiecollector` can be accessed through the targeting data available in the request context. You can use the `TargetingStateProvider` to get the profile and then retrieve the targeting data. Here is an example code snippet:

```auto
TargetingProfile profile = TargetingStateProvider.get().getProfile();
Map<String, TargetingData> targetingData = profile.getTargetingData();
InferenceGoalsTargetingData inferenceGoalsTargetingData = (InferenceGoalsTargetingData) targetingData.get("inferencecollector");

```

Java

- Ensure that you handle the data correctly to avoid class cast exceptions. The targeting data should be cast to the appropriate type.

1. Using the Data in the Expression Inference Rule Engine:

- The data collected by the `cookiecollector` can be used in the Expression Inference Rule Engine. You can set the value of the cookie in the extra data targeting map within your inference rule expression. This value can then be used to set attributes on the request context, which can be utilized in your Freemarker templates or other components.

- Here is an example of how you might set the value in the extra data targeting map:

```auto
// In your inference rule expression
extraData.put("cookieValue", cookieValue);

```

Java

- You can then retrieve and use this value before rendering your components.

1. **Testing the Collector:**

- To test the `cookiecollector`, you can simulate requests with the relevant cookies and verify that the data is being collected and stored correctly. You can use tools like Postman or browser developer tools to set cookies and inspect the requests and responses.
- Additionally, you can log the collected data to ensure it is being captured as expected.

By following these steps, you should be able to test and access the data collected by the `cookiecollector` and use it within the Expression Inference Rule Engine.

Kindly please let me know if this helps ?

Thanks and Regards,  
Rajesh S
