Re: Trying to add clickable link to customer account page

Solved

Trying to add clickable link to customer account page

dariantennis
Tourist
5 0 2

I need to put a link on some of my customers' account pages so that they can access and click the link after signing in. I want to avoid an app if possible. I figured out as a workaround that I can add the link as a "new address" and then make that "address" the default so it will show on my customer's page.  However, the customer is still going to have to copy the link and paste it into a browser. Shopify won't let me enter the link as an anchor tag -- it says no HTML allowed. Any suggestions? I asked a guru how to code in a field to the account page for this purpose and was told it is a "major" coding project.

Accepted Solution (1)
Ninthony
Shopify Partner
2332 350 1034

This is an accepted solution.

So yeah this is possible too. So let's just say you want to link them to google for arguments sake. Tag them like "link--https://www.google.com". Then in the customers/account.liquid page you can loop through them, check if the tag contains 'link', split the tag by the double dash, and put the last part of the tag in an anchor:

{% assign url = false %}

{% for tag in customer.tags %}
  {% if tag contains 'link' %}
    {% assign url = tag | split: '--' | last %}
  {% endif %}
{% endfor %}

{% if url %}
  <a href="{{ url }}">Click here to go to google</a>
{% endif %}

 

 You may want to use a more unique character to split by in case there's any double dashes in any of the urls you provide. Maybe like dollar signs or something. 

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄

View solution in original post

Replies 16 (16)

Ninthony
Shopify Partner
2332 350 1034

What are you linking to? Is this conditional in any way? Like only some customers should see it? There's no reason you can't just put a link in your customers/account.liquid file in your templates folder.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
dariantennis
Tourist
5 0 2

Thanks for replying! Yes, it's conditional. It can't show up on every customer's account page. Only on those that I have manually added it to.  I'm linking to an outside location.

Ninthony
Shopify Partner
2332 350 1034

Tag the customers that you want to see the link, use something like "outside-link" then in the customers/account.liquid file you can say:

{% if customer.tags contains "outside-link" %}
<a href="https://www.google.com">Click here to go to google</a>
{% endif %}

 

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
dariantennis
Tourist
5 0 2

Hmmmm, getting close.. thanks for your patience.

The link is UNIQUE to each customer. I was trying to simplify my question but I failed to give you enough information. I will be selling digital content that is stored outside of Shopify (on Dropbox), and each customer's content is different and thus they need a unique link. Maybe I can tag each customer with their unique link being the tag, then in the customers/account.liquid file, check for the tag and post it on the page (as a link) if it exists. If I can figure out how to do all that lol🙂

 

Ninthony
Shopify Partner
2332 350 1034

This is an accepted solution.

So yeah this is possible too. So let's just say you want to link them to google for arguments sake. Tag them like "link--https://www.google.com". Then in the customers/account.liquid page you can loop through them, check if the tag contains 'link', split the tag by the double dash, and put the last part of the tag in an anchor:

{% assign url = false %}

{% for tag in customer.tags %}
  {% if tag contains 'link' %}
    {% assign url = tag | split: '--' | last %}
  {% endif %}
{% endfor %}

{% if url %}
  <a href="{{ url }}">Click here to go to google</a>
{% endif %}

 

 You may want to use a more unique character to split by in case there's any double dashes in any of the urls you provide. Maybe like dollar signs or something. 

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
dariantennis
Tourist
5 0 2

This is great! I will try it and come back and tag your answer as a solution when I get it working. I like this idea!! Thanks for your prompt replies.

Ninthony
Shopify Partner
2332 350 1034

No problem, as you can see this was a "major" coding project.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
dariantennis
Tourist
5 0 2

LOL I should have come to the forums at the start! Great first experience so far, thank you

andra0412
Tourist
13 0 0

Hi.. I had similar issue. could you help if i want to add a small description and also clickable link on account page? 

So the customer can view this when they are logged in into their account. to access marketing material 

 

thank you so much!

Ninthony
Shopify Partner
2332 350 1034

Hey @andra0412 , so you can definitely do this. Go to Settings > Custom Data > Customers to set up a Customer metafield:

 

Ninthony_0-1699724338015.png

 

Click Add Definition when prompted and you'll be brought to add customer metafield definition. You'll need to name the metafield so call it something like Description with link, add a description for it if you'd like, and then click to add the type of metafield and select Rich text, then click save.

 

Ninthony_1-1699724480434.png

 

Then go to the customer in the admin you want to add the description to and you'll see the new metafield:

Ninthony_2-1699724739460.png

 

Click into it and you can add your description, the rich text editor has some basic editing options like bold, italics, list, and you can add a link in there as well, I'm just gonna link to google

 

Ninthony_3-1699724824658.png

 

Then click save in the top right corner of the screen, should be in the top black bar in the shopify admin

 

Ninthony_4-1699725037238.png

Then in your theme code you're going to want to go into customers/account.liquid in your Templates folder, I'm using Dawn theme. I just want to output it directly under the logout button or whatever:

Ninthony_5-1699725172350.png

 

In the code you'll want to check if the metafield isn't blank, and then output it:

 

{%  if customer.metafields.custom.description_with_link != blank %}
  {{ customer.metafields.custom.description_with_link | metafield_tag }}
{%  endif  %}

 

Ninthony_6-1699725317403.png

 

Then you'll see it in the account page. I'm hovering the link and you can see in the bottom left that it's linking to google.com:

Ninthony_7-1699725372518.png

 

And that's that

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
andra0412
Tourist
13 0 0

thank you so much it worked! but one thing.. i would like this to be in all our customers account. 

and the way you told me i need to add this one by one in customer account. is there any other way i dont need to apply it one by one?

Ninthony
Shopify Partner
2332 350 1034

Oh sorry I misunderstood, I thought it would need to be specific to customer. In that case, most of what I told you was unnecessary lol. So wherever you placed the code in customers/account.liquid -- you'll just need to put some plain HTML for what you want. So instead of the metafield code with the check to see if the metafield was blank that I provided above, just do something like

 

 

<p>Here's some text you want to output on every customer account page. <a href="https://google.com">Here's a link for your marketing information.</a></p>

 

Just replace the text with whatever you want and replaced the "href" attribute with the link that you need to provide everybody.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
andra0412
Tourist
13 0 0

perfect! thanks so much

zabazaba
Excursionist
14 0 1

Just came across this and it worked perfectly.  Only question is, if I wanted to also add the link to the drop down list when they click on their "My account" link in the top menu, how where would I add the if statement?

Fleurs
Tourist
6 0 6

Is there a way to add a link when a customer.tags is not present?  The opposite of the example you have given?  Thanks.

asserty
Visitor
1 0 0

I Want To Redirect My Checkout Button To My Custom Link