# Recognize a user action when using a campaign webhook

**URL:** <https://forum.mautic.org/t/recognize-a-user-action-when-using-a-campaign-webhook/25962>\
**Category:** General Discussion\
**Created:** [November 5, 2022, 4:44pm UTC](https://forum.mautic.org/t/recognize-a-user-action-when-using-a-campaign-webhook/25962 "2022-11-05T16:44:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcarabelli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rcarabelli/32/6807_2.png) [@rcarabelli](https://forum.mautic.org/u/rcarabelli)\
**Post date:** [November 5, 2022, 4:44pm UTC](https://forum.mautic.org/t/recognize-a-user-action-when-using-a-campaign-webhook/25962/1 "2022-11-05T16:44:26Z")

</div>

**Your software**  
My Mautic version is: v4.4.4  
My PHP version is: PHP 8.0 (ea-php80)  
My Database type and version is: MySQL 5.7.40

**Your problem**  
My problem is: I am sending a campaign Webhook to another app and I want to include a way to track the users. Specifically I want to generate a unique link per user to be able to change them from segment if they click in the link (or do any action). I haven’t found any documentation of how to manually create a link or anything to trigger an action in mautic except by built in functions or apps.

In other words:

1. I create a campaign with a segment (with some users in it)
2. I create a webhook to another messaging system to trigger a message in this other system
3. I run the campaign and each person gets it’s message but that message is not personalized (except by the user name because I added in the webhook the user name tag)
4. I want them to click in the included link and when clicking into that link, Mautic will know that user X did a click so it should change of segment in mautic
5. Since I can’t personalize a link in the webhook, I don’t know how to create this trigger for mautic and change segments  
I am adding an image of how I am managing the webhooks on the campaign

These errors are showing in the log: This is not about an error

Steps I have tried to fix the problem: I am adding a webhook and here is the full line of the text content of the message: “Hello {contactfield=firstname}, this is a test message. [https://www.xxxxxxxx.com](https://www.xxxxxxxx.com) Please answer the poll”

I want to find a way to identify the user, I thought about a link but is not dynamic when using webhooks

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/9/9895515c67a372d50f7d23cb47af8573bd8dd954.png)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/a/a7523f9559aeeb547dcb9dbbd9b6eb6eadc6056f.png)

---

<div class="post-metadata">

**Author:** ![rcarabelli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rcarabelli/32/6807_2.png) [@rcarabelli](https://forum.mautic.org/u/rcarabelli)\
**Post date:** [November 5, 2022, 4:55pm UTC](https://forum.mautic.org/t/recognize-a-user-action-when-using-a-campaign-webhook/25962/2 "2022-11-05T16:55:11Z")

</div>

I am thinking about adding a variable at the end of the URL like  
[https://www.my-web-that-have-a-mautic-tag.com/{contactfield=email}](https://www.my-web-that-have-a-mautic-tag.com/%7Bcontactfield=email%7D) or similar, but I am not sure that will be enough for mautic or if I have to add to mautic a way to “read” that email and know that that guy did a clic on the link

---

<div class="post-metadata">

**Author:** ![rcarabelli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rcarabelli/32/6807_2.png) [@rcarabelli](https://forum.mautic.org/u/rcarabelli)\
**Post date:** [November 5, 2022, 10:39pm UTC](https://forum.mautic.org/t/recognize-a-user-action-when-using-a-campaign-webhook/25962/3 "2022-11-05T22:39:28Z")

</div>

Ok, this worked: [Tracking Visitor Data by Smart URL](https://www.mautic.org/blog/developer/tracking-visitor-data-by-smart-url?_ga=2.129600971.616507910.1667585596-1234854976.1665635866)

Thanks @Woeler great solution, now I can add multiple tags or even change fields in my contacts.  
BTW, this is very important to manipulate different fields:

> **[Contact tracking](https://docs.mautic.org/en/contacts/manage-contacts/contact-monitoring)**
>
> . The act of monitoring the traffic and activity of contacts can sometimes be somewhat technical and frustrating to understand. Mautic makes this monitoring simple and easy to configure.Website Monitoring. Monitoring all traffic on a website can be...

```auto
mt('send', 'pageview', {email: 'my@email.com', firstname: 'John', tags: 'whatever-tag-you-want'});

```

Finally, did a little change to the code to be able to send the tags through the link (I am terrible at coding so my solution might be horrible but works):

Note that “v” is the variable of the email and “c” is the variable for the new tag so the link should be: [https://www.yourmauticsite.com/?v=email@email.com&c=the-tag-you-want](https://www.yourmauticsite.com/?v=email@email.com&c=the-tag-you-want)

BTW the code is there but I don’t know how to make it visible or if it’s approved in this forums, so in the image is the code added:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/9/93e820c01c3482c5ddfbc2ea51720f3f00b8add6.png)

Update: I want to send mutiple variables and change multiple tags so the code changed a bit more:

First when declaring variables:

var email = getUrlParameter(‘a’);  
var vartag1 = getUrlParameter(‘b’);  
var vartag2 = getUrlParameter(‘c’);  
var vartagn = getUrlParameter(‘n’);  
var mergedtags = vartag1 + “,” + vartag2 + “,” + vartagn

Then used the mergedtags variable on the line that sends the values to mautic:

```
if(email !== ''){
	mt('send', 'pageview', {email: email, tags: mergedtags});

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [November 7, 2022, 10:39am UTC](https://forum.mautic.org/t/recognize-a-user-action-when-using-a-campaign-webhook/25962/4 "2022-11-07T10:39:53Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
