# Gatsby Custom Targeting

**URL:** <https://forum.builder.io/t/gatsby-custom-targeting/882>\
**Category:** Technical Questions\
**Created:** [August 19, 2021, 6:21pm UTC](https://forum.builder.io/t/gatsby-custom-targeting/882 "2021-08-19T18:21:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chesteralan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/chesteralan/32/470_2.png) [@chesteralan](https://forum.builder.io/u/chesteralan)\
**Post date:** [August 19, 2021, 6:21pm UTC](https://forum.builder.io/t/gatsby-custom-targeting/882/1 "2021-08-19T18:21:27Z")

</div>

Hi Steve,

Is it possible to use custom targeting using gatsby and cookies?

I added 3 pages with similar urlPath and with different whatEverKey values. Then I tried adding this code below somewhere in my code but it’s not filtering my pages.

```auto
builder.setUserAttributes({
  userIsLoggedIn: cookies.get("userIsLoggedIn"),
  whatEverKey: cookies.get("whatEverKey"),
});

```

It always end up with the page that has no additional targeting aside from urlPath. When I added all 3 pages with a targeting `whatEverKey`, nothing is display. The graphql results returns empty.

Please enlighten me with this one.

Thanks,

Chester

---

<div class="post-metadata">

**Author:** ![steve](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/steve/32/78_2.png) [@steve](https://forum.builder.io/u/steve)\
**Post date:** [September 22, 2021, 3:27pm UTC](https://forum.builder.io/t/gatsby-custom-targeting/882/2 "2021-09-22T15:27:09Z")

</div>

hey @chesteralan - you absolutely can, but due to the static nature of Gatsby the cookie targeted values need to run in the browser only. So builder.setUserAttributes() won’t impact the GraphQL responses, but it can be used browser side, such as

```auto
function MyComponent() {
  const [section, setSection] = useState(null);

  useEffect(() => {
     builder.setUserAttributes(...)
     builder.get('section').promise().then(setSection)
  }, [])

  return section ? <BuilderComponent model="section" content={section} /> : null
}

```

---

<div class="post-metadata">

**Author:** ![chesteralan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/chesteralan/32/470_2.png) [@chesteralan](https://forum.builder.io/u/chesteralan)\
**Post date:** [September 22, 2021, 5:54pm UTC](https://forum.builder.io/t/gatsby-custom-targeting/882/3 "2021-09-22T17:54:36Z")

</div>

Thank you much @steve ! I’ll it out.
