# Automatic lead source tracking

**URL:** <https://forum.mautic.org/t/automatic-lead-source-tracking/19583>\
**Category:** Ideas and Feature Requests\
**Tags:** tracking\
**Created:** [May 24, 2021, 3:27pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583 "2021-05-24T15:27:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanicker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanicker/32/5229_2.png) [@hanicker](https://forum.mautic.org/u/hanicker)\
**Post date:** [May 24, 2021, 3:27pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/1 "2021-05-24T15:27:46Z")

</div>

My idea is:

automatically track / tag (new field or tag system) the contact source based on the first browser referral seen, based on some common source lists, eg.:

- coming from google, yahoo, etc. =\> search engine
- coming from a common adv (eg. adword) =\> paid
- coming from social networks =\> social
- any other referral =\> referral
- no referral =\> direct

I think these groups of people would benefit from this idea:  
marketing, analysts

Why I think they would benefit from this idea:  
monitoring source traffic, roe calculation, etc.

Any code or resources to support this idea:  
~something like [GitHub - medius/utm\_form: Add UTM, referrer, landing page and other information to any lead generation form](https://github.com/medius/utm_form) but it is possible to see this feature in other software

Are you willing to work on this idea?:  
Yes, I would like to start working on a PR

What skills and resources do you need to explore this further? -

–  
Hi, I found some closed issues / threads here about this functionality

> [@Lead Source](https://forum.mautic.org/t/lead-source/2301):
>
> I think this would be a new feature - correct me if I’m wrong. I’d like to capture the lead source in one or more fields per lead. It would be very valuable to be able to report on where the leads that are converting are originating from. We do have the referrer information already, but it should be much more detailed like organic search, paid search, website referral, social. Can this be automated or do I have to setup hidden fields and capture the info on first visit and store in a…

> <https://github.com/mautic/mautic/issues/1528>
>
> \## Description
> 
> It would be great that each created lead has been tagged by its …source.
> 
> \*\*Sources could be:\*\*
> \- Organic search (SEO)
> \- Paid search (SEA)
> \- Referrer --\> Then specify the link source
> \### Why?
> 
> \*\*It is a great opportunity to mesure the ROI by acquisition channel.\*\*
> \### Examples of competitor
> \## !\[capture d ecran 2016-03-14 a 13 33 14\](https://cloud.githubusercontent.com/assets/14075239/13744651/74797dc0-e9e9-11e5-9ff2-436eb0e6dcc8.png)
> 
> !\[capture d ecran 2016-03-14 a 13 33 39\](https://cloud.githubusercontent.com/assets/14075239/13744650/74792ec4-e9e9-11e5-91cb-d6d05a68794c.png)
> \## How to use those datas
> 
> We should create a \`lead field\` automatically filled in with the established \`sources values\`.
> \### Filter in Lead Lists
> 
> !\[capture d ecran 2016-03-14 a 13 40 29\](https://cloud.githubusercontent.com/assets/14075239/13744833/dba71e98-e9ea-11e5-8aa6-4547339a2992.png)
> !\[capture d ecran 2016-03-14 a 13 40 43\](https://cloud.githubusercontent.com/assets/14075239/13744834/dbaa4776-e9ea-11e5-8b80-8c50d581d693.png)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [May 24, 2021, 3:37pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/2 "2021-05-24T15:37:48Z")

</div>

Hi there, thanks for the suggestion! We do already have UTM tracking:

> **[Contact tracking](https://docs.mautic.org/en/contacts/manage-contacts/contact-monitoring#utm-codes)**
>
> . 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...

We also merged this PR in Mautic 4:

> <https://github.com/mautic/mautic/pull/9265>
>
> | Q | A
> | --------------------------------…------ | ---
> | Branch? | staging
> | Bug fix? | no
> | New feature? | yes
> | Deprecations? | no
> | BC breaks? | no
> | Automated tests included? | yes
> | Related user documentation PR URL | https://github.com/mautic/mautic-documentation/pull/128
> | Related developer documentation PR URL | 
> | Issue(s) addressed | 
> 
> \#### Description:
> Related to https://forum.mautic.org/t/utm-tag-contact-properties-and-reporting/10320/5
> 
> This PR adds the functionality to record UTM tags for all requests. Including via Javascript (/mtc/event).
> 
> \#### Steps to test this PR:
> 1. Load up \[this PR\](https://mautibox.com)
> 2. Create a landing page
> 3. Open the landing page in incognito mode with utm tags attached to the url. E.g. ?utm\_source=linkedin&utm\_medium=social&utm\_campaign=mautic&utm\_content=testing
> 4. Check the contact history to see if UTM tags are recorded for the anonymous contact. 
> 
> Note that UTM tags are only recorded the first time a user visits a certain page
> 
> If you can test also the js tracking:
> 
> \`\`\`
> curl --location --request POST 'http://domain.ddev.site/index\_dev.php/mtc/event' \\
> \--header 'Content-Type: application/json' \\
> \--data-raw '{
> "page\_title": "Testpage",
> "page\_language": "en-GB",
> "page\_referrer": "",
> "page\_url": "https://www.domain.com/mautic/?utm\_source=linkedin&utm\_medium=social&utm\_campaign=mautic&utm\_content=test",
> "counter": 0,
> "mautic\_device\_id": "qowvkyd2r1232312okcg2qw",
> "resolution": "1792x1120",
> "timezone\_offset": -120,
> "platform": "MacIntel",
> "do\_not\_track": 1,
> "adblock": false,
> "fingerprint": "fqwc25wa2d659c4123c7f5d5789012332"
> }'
> 
> \`\`\`

which should pick up the UTM codes the first time that someone accesses the resources that are being tracked.

Are you suggesting that we should always pick up the referral source and log it based on what is in the browser rather than explicitly look for UTM tags being set?

---

<div class="post-metadata">

**Author:** ![hanicker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanicker/32/5229_2.png) [@hanicker](https://forum.mautic.org/u/hanicker)\
**Post date:** [May 24, 2021, 3:53pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/3 "2021-05-24T15:53:19Z")

</div>

Hi, thanks for your fast reply.  
Yes, maybe not logging the complete referral source (or not only that) but categorizing it against some common lists as done with utm\_medium. In that way it would also cover not-paid / not coming with utm parameters traffic

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [May 24, 2021, 3:56pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/4 "2021-05-24T15:56:14Z")

</div>

OK gotcha - sounds interesting. I think you would not want it on every visit (at large scale that would add a lot of information, I think, and may not be so relevant) but I can see how the first visit or interaction may be helpful if there are no UTM tags already captured.

---

<div class="post-metadata">

**Author:** ![hanicker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanicker/32/5229_2.png) [@hanicker](https://forum.mautic.org/u/hanicker)\
**Post date:** [May 24, 2021, 3:57pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/5 "2021-05-24T15:57:50Z")

</div>

Yes, I completely agree, maybe there should also be an option to enable/disable this tracking, while always giving priority to utm tags if set

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [May 24, 2021, 4:03pm UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/6 "2021-05-24T16:03:35Z")

</div>

Yeah - I think having an option to selectively enable it may be a good call, some folk may not want to ‘guess’ if it is not explicitly set.

---

<div class="post-metadata">

**Author:** ![ledzee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ledzee/32/4252_2.png) [@ledzee](https://forum.mautic.org/u/ledzee)\
**Post date:** [May 27, 2021, 5:10am UTC](https://forum.mautic.org/t/automatic-lead-source-tracking/19583/7 "2021-05-27T05:10:00Z")

</div>

This is a relevant use case.  
So this could possibly also be something of an calculated field. That is, stamp a field (Original Source) with an UTM value (Latest Source) if the original value is empty.

Here is a another relevant discussion on the topic:

> [@Dynamic ("Calculated") Values in Campaign Actions](https://forum.mautic.org/t/dynamic-calculated-values-in-campaign-actions/13736/3):
>
> This would be a great feature. Some of the use cases of calculated fields I can think about are as follows: A formula field that could do a timestamp on a field when another field changes A formula field that could follow a logic of if, then… A formula that could do math operation (+,-,\*,/) as well as functions like SUM, AVG, MEAN, MEDIAN
