CMS Development

egonzalez
Contributor | Elite Partner
Contributor | Elite Partner

Get URL from CTA

SOLVE

Is it possible to get the URL or link from a CTA? something like this:

{{ cta('9ef5c543-11d6-453e-860d-50699c2a581e').link }}

or

{{ cta('9ef5c543-11d6-453e-860d-50699c2a581e').url }}

I want it in a blog post. Or custom module.


Thanks in advance

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

Get URL from CTA

SOLVE

@egonzalez - You could probably do something like this to get the URL of the CTA;

replace the XXXXX with your CTA ID

{% set splitArray = cta('XXXXXXX-XXXX-XXX-XXXX')|split('href="', 2) %}
{% set CTAUrlArray = splitArray[1]|split('"', 2) %}
{% set CTAUrl = CTAUrlArray[0] %}
{{CTAUrl}}

Although, CTA links have pretty standard prefixes and you could probably just do:

 

https://cta-redirect.hubspot.com/cta/redirect/{PORTALID}/XXXXXXX-XXXX-XXX-XXXX

 


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

View solution in original post

5 Replies 5
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Get URL from CTA

SOLVE

@egonzalez - You could probably do something like this to get the URL of the CTA;

replace the XXXXX with your CTA ID

{% set splitArray = cta('XXXXXXX-XXXX-XXX-XXXX')|split('href="', 2) %}
{% set CTAUrlArray = splitArray[1]|split('"', 2) %}
{% set CTAUrl = CTAUrlArray[0] %}
{{CTAUrl}}

Although, CTA links have pretty standard prefixes and you could probably just do:

 

https://cta-redirect.hubspot.com/cta/redirect/{PORTALID}/XXXXXXX-XXXX-XXX-XXXX

 


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

egonzalez
Contributor | Elite Partner
Contributor | Elite Partner

Get URL from CTA

SOLVE

Thanks. Solved. Have a nice day, and you too reader.

0 Upvotes
Stephanie-OG
Key Advisor

Get URL from CTA

SOLVE

I don't believe that's possible, the HubL documentation shows that it only takes two parameters:

 

The first parameter is the GUID of the CTA. This unique ID can be found in the URL of the Details screen of a particular CTA. The second parameter accept the following enumeration values:

  • justifyleft - adds text-align: left to the CTA wrapper.
  • justifycenter- adds text-align: center to the CTA wrapper.
  • justifyright - adds text-align: right to the CTA wrapper.
  • justifyfull - adds no justification to the CTA wrapper.

 

I also can't spot any filters that would help either. 

 

What's the use case for just getting the URL for the CTA?

 


Stephanie O'Gay GarciaHubSpot Design / Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

 

0 Upvotes
egonzalez
Contributor | Elite Partner
Contributor | Elite Partner

Get URL from CTA

SOLVE

Hi, thanks for the response.

I want to do it because I am making a parallax CTA. You can see it here: https://blog.dinterweb.com/lenguaje-para-la-web-tuteo-ustedeo-o-voseo

The HTML code is:

 

<a href="https://wvw.dinterweb.com/ebook-el-tiempo-la-mejor-analogia-para-entender-la-evolucion-del-marketing?hsCtaTracking=9ef5c543-11d6-453e-860d-50699c2a581e%7C0598f485-7009-4e92-a00a-0e14f4913c42">
<div class="dinter_cta col-xs-12 col-sm-12 col-md-12" data-paroller-factor="0.4" data-paroller-factor-xs="0.2">
<div class="col-xs-12 col-sm-6 col-md-6 img" style="background-image: url('https://wvw.dinterweb.com/hubfs/ebooks/ctas/analogia.png');">&nbsp;</div>
<div class="col-xs-12 col-sm-6 col-md-6 info">
<p>Descubrí cómo utilizar el marketing para dar un paso hacia el <span>desarrollo empresarial</span>.</p>
{{cta('9ef5c543-11d6-453e-860d-50699c2a581e')}}</div>
</div>
</a>

 

In the first <a> element; I want to make something like: {{ cta('9ef5c543-11d6-453e-860d-50699c2a581e').link }} in the href attribute, not to copy all the url of the CTA redirect.

I do not know if I am explaining myself correctly.

Thanks. 😛

0 Upvotes
Jsum
Key Advisor

Get URL from CTA

SOLVE

@egonzalez,

 

The cta creator uses a richtext editor and the richtext editor has a source code editor. From looking at code I can see that you shouldn't have any issues inserting it into the source code editor of the richtext editor of a cta. This means you can create your parallax cta, very cool btw, and let the cta manager wrap it inside the cta. This way you don't have to try to tear the cta apart. If you do this make sure you set the cta style to 'no style' to clear any default styling. You can keep your css in your style sheet. 

 

 

Need help? Hire Us Here

0 Upvotes