Display information based on url factors

SOLVE
Regular Contributor

 

We have a Mortgage Company with many Loan Officers (reps). Their website currently displays the corporate phone number in the header and corporate liscence information in the footer. We want their reps to be able to direct traffic back to the site with a unique url that then sets the header and footer to display that reps phone numebr and liscense info for the balance of the session (or permanantly or until they visit another reps links directly.)

 

I know I can use smart content and have different content displayed based on campaigns. For testing purposes I added ?utm_campaign=js to the end of a hubspot landing page I was viewing. I had set the header to be smart and display John Smith's contact info when the campaign was JS. I also manually added ?utm_campaign=js to every link in the naviation that is displayed when the campaign is js, this way every page you visit holds onto that campaign=js designation. This works but there are issues.

 

Any link on those pages does not have the campaign forced onto the url, so as soon as you click anything other than the header navigation, you arrive at a generic version of the site. Maybe this would be possible to make all content smart but there are too many reps and too many pages to manually manage this. Additionally, there are avenues like the blog listings that can not be controlled this way.

 

How do we get that campaign information to stay with the visitor? 

 

I believe there is a way with HubL to make content display differently based on factors. I just do not know how to set those factors. What I think I am looking for is a way to universally add ?utm_campaign={{something.campaign}} to the end of all links on the site, and a way to set that something.campaign value. And at that point campaigns is probably not the value we are looking to set. 

 

Am I way off with this? As you can tell I only know enough to be dangerous. Any direction would be appreciated.

Reply
0 Upvotes
3 Accepted solutions

Accepted Solutions
Regular Contributor | Platinum Partner

You can have different approachs here, but I guess that the easy way to manage this kind of stuff is by JavaScript.

 

And by JS you also have to choose different ways, for example:

  1. You can do a script to manage if the variable in the URL exist and then when the visitor click in a link modify the link to load with the variable.

  2. You can do a script to save the variable in a cookie and use it for each load. I am not sure if the smart content will recognice the cookie automatically but if it does probably this is the best solution. If not, I guess that the optimal solution will be the 1.

 

I hope this could help you! Smiley Happy

 

Regards,

Gonzalo

 

 

Regular Advisor

If your looking to use HUBL in the template, you can use the {{ request.query_dict }} variable and if statements.

 

{% if request.query_dict.utm_campaign == "something" %}

<p>something html</p>

{% elif request.query_dict.utm_campaign == "something else" %}

<p>something else html</p>

{% else %}

<p>default html</p>

{% endif %}

 

Regular Advisor

Try this

 

{% set rep_phone_jon_smith = "Jon's Number" %}

{% set rep_phone_jill_jones = "Jill's Number" %}

 

{% set contact_rep = "{{rep_phone_" ~ request.query_dict.rep_first ~ "_" ~ request.query_dict.rep_last ~ "|default('888-333-1374') }}" %}


    <p> {{ contact_rep }} </p>

11 Replies
Regular Contributor | Platinum Partner

You can have different approachs here, but I guess that the easy way to manage this kind of stuff is by JavaScript.

 

And by JS you also have to choose different ways, for example:

  1. You can do a script to manage if the variable in the URL exist and then when the visitor click in a link modify the link to load with the variable.

  2. You can do a script to save the variable in a cookie and use it for each load. I am not sure if the smart content will recognice the cookie automatically but if it does probably this is the best solution. If not, I guess that the optimal solution will be the 1.

 

I hope this could help you! Smiley Happy

 

Regards,

Gonzalo

 

 

Regular Contributor

Thanks Gonzalo. Number 1 does sound like a solution to keeping the campaign following a user around the site. Basically javascript that says if the url contains a campaign, append it to the link when clicked.

 

 

Sounds good. We will look into it. Thanks again!

Reply
0 Upvotes
Regular Advisor

If your looking to use HUBL in the template, you can use the {{ request.query_dict }} variable and if statements.

 

{% if request.query_dict.utm_campaign == "something" %}

<p>something html</p>

{% elif request.query_dict.utm_campaign == "something else" %}

<p>something else html</p>

{% else %}

<p>default html</p>

{% endif %}

 

Regular Contributor

Perfect. This will save me from having to set 50 smart rules for every element that displays a phone numer. Thank you!

Regular Contributor

 

So this has lead me to another idea. If the visitor did not start at a reps landing page, but has a hubspot owner, is there a similar HubL string that could display info based on hubspot owner?

 

 

I could not find Contact Owner as a hubl supported variable here. http://designers.hubspot.com/docs/hubl/hubl-supported-variables

 

 

 

 

Reply
0 Upvotes
Regular Advisor

Any contact property is accessible hubspot via the {{ contact }} variable. just add a period(.) and the property id. For the hubpsot owner, it would be. {{contact.hubspot_owner_id}}. However this is just the ID. You may also want to play around with the {{owner}} variable and see if that works. It includes full name {{owner.fullname}}, first name {{owner.firstname}}, last name {{owner.lastname}}, and email {{owner.email}}. I haven't tested to see if it would work or not.

 

 

 

Reply
0 Upvotes
Regular Contributor

I will test these. Thanks.

 

To confirm, in theory, the following would check for contact owner first and display that owners contact info. If owner is not known it would then check for campaign.

 

{% if contact.owner.fullname == "John Smith" %}
<p>John's Info</p>
{% elif contact.owner.fullname == "Jill Smith" %}
<p>Jill's Info</p>

{% elif request.query_dict.utm_campaign == "jon-leads" %}
<p>John's Info</p>

{% elif request.query_dict.utm_campaign == "jill-leads" %}
<p>Jill's Info</p>
{% else %}
<p>Default Info</p>
{% endif %}

 

Considering we are making this work for 50 reps, this is going to get pretty long. So next, I am exploring storing the rep's information is a dictionary. I am just not totally clear where to save the variable information to. Should this be done in the head before the closing tag? Or maybe saved in the template header?

 

{% set repinfo_john_smith = “phone number, email address, license number” %} ---›Where do I save this?‹---

 

{% if contact.owner.fullname == "John Smith" %}
<p>{{ repinfo_john_smith }}</p>

Reply
0 Upvotes
Regular Advisor

 You would need to use nested if statements. first checking for owner and then for query parameter.

 

{% if owner %}

    {% if owner.fullname == "John Smith" %}
    <p>John's Info</p>
    {% elif owner.fullname == "Jill Smith" %}
    <p>Jill's Info</p>

    {% else %}

    <p> default if lead has owner, but doesn't have a match above<p>

    {% endif %}

{% elif request.query_dict.utm_campaign %}

    {% if request.query_dict.utm_campaign == "jon-leads" %}
    <p>John's Info</p>

    {% elif request.query_dict.utm_campaign == "jill-leads" %}
    <p>Jill's Info</p>
    {% else %}
    <p>Default Info if has utm_campaign, but doesn't match above</p>
    {% endif %}

{% else %}

<p>Default Info if no owner or  utm_campaign</p>

{% endif %}

 

or you can check owner and query parameter in the same if statement.

 

 {% if owner.fullname == "John Smith" or  request.query_dict.utm_campaign == "jon-leads" %}
    <p>John's Info</p>
    {% elif owner.fullname == "Jill Smith" or request.query_dict.utm_campaign == "jill-leads" %}
    <p>Jill's Info</p>

    {% else %}

    <p>Default Info if no owner or  utm_campaign</p>

{% endif %}

 

You can add the set variable info in a HUBL module within the template.

Not sure if you are using the COS website add-on. If so, they just released the HubDB which may help with storing the rep info. I haven't taken a look at it yet, so I can't really give you an insight into using it.

 

Reply
0 Upvotes
Highlighted
Regular Contributor

I am having trouble with this code, trying to nest information from the url in other variables. This is what I am working with, but {{rep_phone_{{rep_first}}_{{rep_last}} }} does not seem possible. Any suggestions how I can pull a variable from a url and have that variable set in another variable?

 

URL.com?rep_first=jon?rep_last=smith

 

{% set rep_phone_jon_smith = "Jon's Number" %}

{% set rep_phone_jill_jones = "Jill's Number" %}

 

{% set rep_first = "{{request.query_dict.rep_first}}" %} {% set rep_last = "{{request.query_dict.rep_last}}" %}

 

{% if rep_first == "{{rep_first}}" and rep_last == "{{rep_last}}" %} <p> {{rep_phone_{{rep_first.value}}_{{rep_last.value}} }} </p> {% else %} <p>888-333-1374</span></p> {% endif %}

 

--

 

Thanks.

Reply
0 Upvotes
Regular Advisor

Try this

 

{% set rep_phone_jon_smith = "Jon's Number" %}

{% set rep_phone_jill_jones = "Jill's Number" %}

 

{% set contact_rep = "{{rep_phone_" ~ request.query_dict.rep_first ~ "_" ~ request.query_dict.rep_last ~ "|default('888-333-1374') }}" %}


    <p> {{ contact_rep }} </p>

Regular Contributor

Works perfectly. Thanks very much. You have changed my HubL life for the better!

 

Landing Page - info.merchantproexpress.com/credit-card-processing-sales-information

Rep Landing Page - www.merchantproexpress.com/sales-info-dave-linder

Reply
0 Upvotes