<p>Assuming this is for Craft 2, there are a few cookie plugins that let you read and write cookie values from a Twig template.</p>

<p><a href="https://github.com/nystudio107/cookies" rel="nofollow noreferrer">https://github.com/nystudio107/cookies</a></p>

<p><a href="https://github.com/lewisjenkins/craft-lj-cookies" rel="nofollow noreferrer">https://github.com/lewisjenkins/craft-lj-cookies</a></p>

<p><a href="https://straightupcraft.com/craft-plugins/?q=cookie" rel="nofollow noreferrer">https://straightupcraft.com/craft-plugins/?q=cookie</a></p>

CC BY-SA 3.0
2018-01-04T21:29:06.503Z
2018-01-04T21:29:06.503Z
Brad Bell
<p>I want to add source tracking to my Craft CMS site.  Using Google Analytics I can track users through just about the entire process but can't see them as they go through account registration.  </p>

<p>I want to simply add a query parameter to the <code>{{ link }}</code> from the activation email. </p>

<p>I can see that if I add <code>{{ link }}&amp;source=test</code> that the additional query param shows up, however what I really want is something like this:</p>

<p><code>&amp;source={{ craft.request.getCookie('traffic_src') }}</code></p>

<p>However the above solution returns the activation code and <code>source=</code> which leads me to believe that it is undefined</p>

<p>What is the best way to approach this problem of accessing a cookie for a user in one of Craft's email messages.</p>

<craft-features>
Access Site Cookie From Email Message
# Access Site Cookie From Email Message

(Asked by: username_0 on 2018-01-04)

I want to add source tracking to my Craft CMS site. Using Google Analytics I can track users through just about the entire process but can't see them as they go through account registration.

I want to simply add a query parameter to the `{{ link }}` from the activation email.

I can see that if I add `{{ link }}&source=test` that the additional query param shows up, however what I really want is something like this:

`&source={{ craft.request.getCookie('traffic_src') }}`

However the above solution returns the activation code and `source=` which leads me to believe that it is undefined

What is the best way to approach this problem of accessing a cookie for a user in one of Craft's email messages.

**Tags:** craft-features


---

## 1 answers

### Answer by username_1 on 2018-01-04. Score: 0 | Accepted answer

Assuming this is for Craft 2, there are a few cookie plugins that let you read and write cookie values from a Twig template.

<https://github.com/nystudio107/cookies>

<https://github.com/lewisjenkins/craft-lj-cookies>

<https://straightupcraft.com/craft-plugins/?q=cookie>


---

