CMS Development

mgoswick
Contributor

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

We deployed the private content and membership manager on our website, built on the HubSpot CMS. We ran into an issue where the login parameters are not working when checked in HubL. Specifically, I wanted to adjust menu items based on if the user is logged in or not. Below is the code.

 

 <ul>
      <li>{% if request_contact.is_logged_in == true %}Hi, {{ contact.firstname }}{% else %}<a href="http://www.domain.com/_hcms/mem/login" rel=" noopener">Member Login</a>{% endif %}</li>
      {% if request_contact.is_logged_in %}<li><a href="https://www.domain.com/_hcms/mem/reset/request">Reset Password</a></li>{% endif %}
      <li><a href="https://www.domain.com/profile">Community Profile</a></li>
      {% if request_contact.is_logged_in %}<li><a href="http://www.domain.com/profile" rel=" noopener">Portal</a></li>
      <li><a href="https://www.domain.com/advisory/schedule">Priority Scheduling</a></li>{% endif %}
      <li><a href="https://www.domain.com/search">Site Search</a></li>
      {% if request_contact.is_logged_in %}<li><a href="http://www.domain.com/_hcms/mem/logout ">Sign Out</a></li>{% endif %}
 </ul>

 

On the main domain (www.domain.com), the HubL works as expected, substituting "Hi, {{First Name}}" for "Member Login" and adding in the extra links. But on our blog subdomain, (blog.domain.com), these if statements always return false, even when the user has logged in. I'm assuming this has to do with the way cookies are cached and checked when a user logs in, but it seems odd that it does not work across domains, considering the password protection is only based on lists and can be applied across domains. Is this intended behavior, and is there a workaround for this?

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

Here's the reply I got from a Hubspot dev on this issue:

 

"This is currently by design because we don’t know if you want to share the login across domains. We default to the more secure option. We may expose this as an option in the future."

 

So, unfortunately, at this time the request_contact.list_membership work around is all that can be done.

 

Alyssa Wilie
Web Developer

LyntonWeb

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

9 Replies 9
DanielSanchez
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

Hi Mgoswick,

 

I send an option that is not exactly for logged in users, but that allows you to customize content based on contact property.

 

First, u need create this property:

1-contact-prop-create.PNG

 

After, you should create one rule CSS to show onde menu and hide other. Look my example:

 

HTML

<div class="menu-test default-{{ contact.test_validation }}">{% menu id="{{ module.menu_field }}" %}</div>
<div class="menu-test version2-{{ contact.test_validation }}">{% menu id="{{ module.menu_logged }}" %}</div>

CSS:

.menu-test{
  display:none;
}

.default-default{
 display:block;
}

.version2-Version2 {
  display:block;
}

And the preview shows only the menu based on the contact property.

only-one-menu.PNG

The property value, I set as a CSS class that applies a display: block, to a contact that defaults to display: none.

 

Obs: This property that I created below is for example only. In this case you can rely on a property set after a contact completes a form, or other HubSpot action.

 

Hope this helps.

alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

From my understaing of Hubspot Membership the logged in state would only work on pages set to Private. Are there pages on your main domain not set to private where your is_logged_in is working? If not, a workaround you could use is just checking if the user is in the list being used for membership.

 

{% if "XXXX" in request_contact.list_memberships %}
  <!-- logged in html -->
{% else %}
  <!-- logged out html -->
{% endif %}

XXXX being the number ID of the list.

Alyssa Wilie
Web Developer
LyntonWeb

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
mgoswick
Contributor

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

Yes, it works on all pages on the main domain. I have a menu item that is only visible if members are logged in, and it works on all pages, which is why I was surprised it did not work across sub-domains. With that said, the list membership might be a good workaround, since private membership is tied to a particular list anyways and all our membership is tied to a single static list.

 

Either way, it would be good to know if list membership is meant to not be cross-domain, or if there is a way to make those tokens cross-domain.

 

Thanks @alyssamwilie and all helping with this.

alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

That is strange then why it wouldn't be working on the subdomain as the hubspotutk cookie does use a wildcard domain so as to encompass even subdomains. Do you have any landing/website pages on a subdomain where the variable won't work? Wondering if it's just an issue with blogs or the subdomain as a whole.

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
0 Upvotes
mgoswick
Contributor

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

It's definitely the subdomain, as we use the blog tool to host press releases on domain.com/press-release and the menu works correctly with showing and hiding the menu items.

0 Upvotes
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

Here's the reply I got from a Hubspot dev on this issue:

 

"This is currently by design because we don’t know if you want to share the login across domains. We default to the more secure option. We may expose this as an option in the future."

 

So, unfortunately, at this time the request_contact.list_membership work around is all that can be done.

 

Alyssa Wilie
Web Developer

LyntonWeb

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
mgoswick
Contributor

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

That both makes sense and is unfortunate. It's problematic as the workaround would apply styling even when they are not logged in, as long as the browser was cached as that person (an email on any submission form). In practice, the workaround should not have a large impact on the UX in this particular case, but would in cases where you want to display non-confidential, sensitive information (like subscription level) after someone has logged in.

 

Regardless, thanks for all the help with this!

0 Upvotes
sharonlicari
Community Manager
Community Manager

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

Hey @mgoswick 

 

 I will tag a few of our experts Emoticono feliz     

 

Hey @alyssamwilie @DanielSanchez @dennisedson  could you please share your knowledge with @mgoswick ?

 

Thank you,

Sharon 


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Cross Domain tracking not working for HubL Markup and Membership Content

SOLVE

@mgoswick , i have never tried this.  I would have to build it out and test.  Will give it a shot and get back to you in the next day or so

Maybe someone will be quicker than i 🙂