Skip to main content
Question

Is there a generic url for the logged in user profile?

  • May 20, 2026
  • 9 replies
  • 63 views

jvdc

I would like to include into some coms a link to the profile of users, not the settings page, the main profile page where we can see the badges etc...

9 replies

Mithila Jayalath

@jvdc can you give more context on our usecase?


jvdc
  • Author
  • Expert ⭐️
  • May 20, 2026

I want to include in communications, for example when a badge get awarded user are receiving an email notification, I would like to add a button/link “View badge on your profile”


DannyPancratz
Forum|alt.badge.img+9
  • VIP ⭐️⭐️⭐️⭐️⭐️
  • May 20, 2026

community.{your-domain}.com/members/user-{userId}

The only things that matter after /members/ are the hyphen and the userId. You could put any text there or just a single character. The userID actually routes the link; it’s how links still work even if a username change. (Same thing for post links where the title / category changes)


jvdc
  • Author
  • Expert ⭐️
  • May 20, 2026

but I understand {userId} isn't an accepted variable, is it?


DannyPancratz
Forum|alt.badge.img+9
  • VIP ⭐️⭐️⭐️⭐️⭐️
  • May 20, 2026

Good call out; I didn’t connect the dots with your requirement. 

I”m not sure if it’s an available variable in system items. 


Mithila Jayalath

@jvdc how do you trigger the email when you award the badge?


jvdc
  • Author
  • Expert ⭐️
  • May 20, 2026

It's just the email that comes with the badge settings

 


Mithila Jayalath

@jvdc Natively, there is no direct way to link to a user profile from badge notifications emails. This limitation exists because the email template engine only whitelists two specific variables for badge messages: {user-name} (the member's username) and {badge-name} (the title of the badge). Because the numeric user ID variable is unavailable in this context, you cannot dynamically construct the standard profile URL format (community.{your-domain}.com/members/username-{userId}).

However, here’s workaround for this.

Step 1: Update Your Badge Email Template Button

<your_community_url>/p/find-profile?user={user-name}

Email Button HTML Example:

<!-- Profile Button -->
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border-radius: 4px;" bgcolor="#000000"><a style="padding: 12px 16px; border-radius: 4px; color: #ffffff; text-decoration: none; display: inline-block;" href="<your_community_url>/p/find-profile?user={user-name}" target="_blank"> View your profile </a></td>
</tr>
</tbody>
</table>

Step 2: Create the Custom Router Page

  1. Navigate to your Gainsight Community Control Panel and create a new Custom Page.

  2. Set the URL Slug / Path to: find-profile (This establishes the full URL as <your_community_url>/p/find-profile).

  3. Ensure the page visibility is set to logged in users.

Step 3: Add the Router Script to the Custom Page

Add an HTML widget to your newly created custom page and paste the following routing script:

<div style="text-align: center; margin-top: 120px; font-family: 'Helvetica Neue', Arial, sans-serif; color: #333333;">
<div class="profile-loader"></div>
<h2 style="font-size: 22px; font-weight: 600; margin-bottom: 8px;">Loading your profile...</h2>
<p style="font-size: 14px; color: #666666;">We are directing you to your community achievements.</p>
</div>

<style>
.profile-loader {
border: 4px solid #f3f3f3;
border-top: 4px solid #0052cc;
border-radius: 50%;
width: 44px;
height: 44px;
animation: spin 0.8s linear infinite;
margin: 0 auto 24px auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>

<script>
document.addEventListener("DOMContentLoaded", function() {
// 1. Extract the username parameter from the email link (?user=Mithila%20Jayalath)
const urlParams = new URLSearchParams(window.location.search);
const targetUser = urlParams.get('user');

if (targetUser) {
// 2. Silently query the public search results page in the background
fetch('/search?q=' + encodeURIComponent(targetUser))
.then(response => response.text())
.then(htmlContent => {
// 3. Scan the raw HTML for the unique profile URL format (/members/name-id)
const profileUrlRegex = /\/members\/[a-zA-Z0-9_\-.%]+-\d+/;
const match = htmlContent.match(profileUrlRegex);

if (match) {
// 4. Match found! Instantly route them to their public profile
window.location.href = match[0];
} else {
// Fallback: If profile isn't indexed yet, send them to the search results safely
window.location.href = '/search?q=' + encodeURIComponent(targetUser);
}
})
.catch(() => {
// Error fallback: send to search page
window.location.href = '/search?q=' + encodeURIComponent(targetUser);
});
} else {
// Safe fallback: No user parameter found, bounce to homepage
window.location.href = '/';
}
});
</script>

 

How this performs in action:

  • When a user clicks the email button: They are immediately sent to your public find-profile page.

  • During the split second they see the loader: The background JavaScript executes a lightning-fast fetch request against the search page, grabs the text contents, extracts the specific string containing the profile URL (including that hidden user ID number), and forces the browser forward.

  • The destination: The user lands directly on their clean, public profile overview where they can see their badges

Let me know if this workaround works for you :)


jvdc
  • Author
  • Expert ⭐️
  • May 21, 2026

@Mithila Jayalath thanks

I did not try your solution in the end… as I thought of simply creating a custom page that lists all the badges earned by the user and the ones remaining to be earned (custom widget), and I'll link those notification to that page.