Showing results for 
Show  only  | Search instead for 
Did you mean: 

Neat idea: Add Google Analytics tracking codes to your community emails

I just implemented a pretty nifty little enhancement - I added Google Analytics tracking codes (UTM) to each of the links in the standard Lithium-sent emails. So, now I have some visibility into how much traffic these emails are generating.


It has been just over 24 hours since launch, so I don't have a ton of results, but it's really nice to know this data will be trickling in! 


I thought others may be interested in doing this to get some visibility into email usage. It's easy - just add the appropriate UTM codes to each of the URLs in each end-user-visible message template via Studio. I decided to use source=communitymembers and medium=email for each of them, since I'm already using that scheme in marketing emails. For the campaign, I'm using the name of the template (the name from the URL, such as immediate_general for the "General Subscription Notification")


Example: An updated URL in the "General Subscription Notification" email (available in Studio at: https://[STAGING-URL]/t5/bizapps/bizappspage/tab/community%3Astudio%3Atext-editor%3Aemail?email=immediate_general&lang=en):

<a href="${notification.message.webUi.url}?utm_source=communitymembers&utm_medium=email&utm_campaign=immediate_general">${notification.message.subject}</a> 

Some early results are that the "General Subscription Notification" (immediate_general) is leading the pack in terms of clicks:




19 Replies 19

So this is neat - I just awarded badges to 1,100 members based on certifications they've earned outside the community - and I can see that 199 people clicked on the badge notification email to see their badge. 18% clickthrough is pretty great!





Thanks for sharing!

I wonder, do you have a way of knowing how often a certain notification is send and then how often the links are clicked.

I like the idea of trying this but thus far have not been seeing a way to know the total nr of notifications send out.



Learning from others and helping where I can!
Community Passionista!

Yes this would be a great feature to have and add!

@Wendy_S wrote:

I wonder, do you have a way of knowing how often a certain notification is send and then how often the links are clicked.


Hi @Wendy_S -


Just realized I never responded to this one. Nope, I don't know how often a certain notification is sent, just how often the links are clicked. But it's a start!



Yes it is a start and actually it is a good start.

For example: Normally you see that there is active thread, people are posting a lot and you see how many different user are posting. With these tags you can track how many times members comes to the community because they got email ”You got new answers” but they dont post to the thread —> you see perspective how interested members are about that thread anyways (they have posted earlier but they dont want to post any more etc but they are still interested).


My Ideas, please vote:

Syndications | Comments list | Missing-features 

Renew the quote feature

Added codes today, tomorrow morning I push changes to production. Interesting to see the first data 🙂


My Ideas, please vote:

Syndications | Comments list | Missing-features 

Renew the quote feature


@CarolineSdo you use this just for marketing emails or can you use it in notification emails on links like 'reply' 'accept solution' etc?

Hi! I haven’t tried it on the “reply”/“kudos” links... I don’t think... but it’s on other links within notification emails (eg the link to the original post)

I can see that Atlas Community has used this UTM on it’s ‘give kudos’ link so it must be possible! Thanks @CarolineS  🙂

Don't the URLs in many of the email notifications have anchors (eg. #M3214) when referencing a post? I would assume that putting tracking parameters on the end of this URL would either break the tracking or break the anchor (or both).

@CarolineS you seem to have the tracking coming through, have you done this with any notifications that include a post URL? If so, what was the experience like?

A most excellent question, @DanK. I looked up the code I added to the email templates, and it's along the lines of:


<a href="${notification.messageUrl}?utm_source=communitymembers&utm_medium=email&utm_campaign=subscription_digest">View</a>


This creates links like:

The "?" in this URL then seems to automatically convert into the URL-encoding for the "?", or %3F - see below:

Which means I'm actually not getting tracking for these links that have anchors! Good to know! Not sure if there's a solution to this? Any ideas?


I was playing around yesterday as I am keen on getting tracking into our templates for the exact reasons that you did.

One thing that I did discover is that you can do is change the URL variable ${notification.message.webUi.url} to ${notification.message.discussion.webUi.url} and it will return the URL for the topic rather than the post, which means that it does not take the user directly to the message in question (removing the # anchor parameter). This makes the tracking work but it doesn't take the user to the specific comment that generated the notification.

This is okay in a situation where a solution is involved on my community, as we float those to the top, but I suspect it would be a poor user experience for a reply notification in the instance of a multi-page thread as it wouldn't even take the user to the right page let alone the right comment.

When replying to this specific thread here I noticed that the Khoros Atlas team have actually put the codes on the end of the URL and encountered the same issue;

I am not 100% sure how the email templates work but I suspect to get a good user experience you would need to be able to store variables as strings, cut them up and them put back together with the tracking between the URL and the anchor strings. Perhaps someone with a bit more dev in their title could work something out 😛


@DanKgood find that Khoros themselves have this error too! Agree that it’s not a great solution to just remove the anchor, especially as some discussions get looooooong. 

I do wish Khoros would just provide some amount of email tracking so we didn’t need this hacky solution anyway!


Okay, so it has been ~15 years since I dropped out of my programming course at uni so there may be a more elegant solution than I have found BUT I have found a way to keep the anchor.

I have highlighted in red the parts that you will need to change to suit your requirements but basically the code below takes the URL, checks for a # and if one is found splits it into two text strings (one containing the URL without the anchor and the second containing just that value eg. #M1234 ). Then the URL is reconstructed by inserting your UTM parameters between the two parts and setting it as a variable you can use

#set ( $tempurl = ${notification.message.webUi.url})#if( $tempurl.contains('#'))
#set ($hashindex = $tempurl.indexOf('#'))
#set ($urlstart = $tempurl.substring(0,$hashindex))
#set ($urlend = $tempurl.substring($hashindex))
#set ($tempurl = "${urlstart}?utm_source=community&utm_medium=email${urlend}")
#set ($tempurl = "${tempurl}?utm_source=community&utm_medium=email")

I put this code towards the top of the template and then simply used my new variable $tempurl in place of all references to the message url within the template.

Note that the code must precede any attempts to use the variable or it will break (hence why I put it towards the top).

EDIT: I just realised the original solution did not put tracking on when the URL had no # (although I will be using it where I KNOW a # exists) so I have added an else statement to do that.

Wow, @DanK, awesome! I'll steal this!

Thanks @DanK !


Great thread everyone!  Does this give you more than the 'newish' Analytics section titled Email?  See the screenshot below:




I have the same question. Does this benefit you more than the reports in Community Analytics?

@HelgaMarieAuranWhat Khoros has baked in is probably better - Google Analytics is really for the rest of us that can't take advantage of the Khoros email analytics I would say (Which seems to be the majority unfortunately). Various technical reasons prevent it.

Welcome to the Technology board!

Curious about our platform? Looking to connect on social technology? You've come to the right place!

Are you a Khoros customer? For direct assistance from our Support team, please visit the Support Forum.