CMS Development

MKukanjac
Member | Diamond Partner
Member | Diamond Partner

Get page/blog post id from CTA button

Hey,

 

I am trying to replace a CTA button from around 300 pages 🙂 All of the CTA buttons are linked to internal pages/blog posts.

 

Need to do this since CTA links don't count as internal links, so I need to replace them with <a href="XXX">Link</a>

 

Is it possible to get the page id or absolute URL to the page that the CTA button is linking to?

 

I can only extract the CTA button id and the redirect URL.

 

Has anyone had a similar experience?

0 Upvotes
3 Replies 3
FabianRichter
Contributor

Get page/blog post id from CTA button

Hi,

I am not sure, if I got you right. You can get the linked page of the CTA in the edit mode of the CTA or simply by clicking on it.

The easiest wey to get the ID of the page/blog post, is to simply click the CTA button and in your HubSpot menu go to "edit page". The ID is inside of your URL then: app.hubspot.com/pages/<your_portal>/editor/<your_id>/content

 

Hope this helps.

Best,
Fabian

0 Upvotes
MKukanjac
Member | Diamond Partner
Member | Diamond Partner

Get page/blog post id from CTA button

Hey Fabian,

 

Sorry, I wasn't clear, but I was referring to the HUBL code. If I use a CTA field in the code and generate the CTA by using the CTA id, I only get the redirect URL that eventually leads to the real URL.

 

For example, the function that generates the CTA: cta('CTA_BUTTON_ID'). I could get a lot of data from it by using pprint, but no page id nor the absolute URL

 

I wanted to see if it's possible to get the page id or the absolute URL to that page from this CTA field.

 

I finally managed to do it with JavaScript since I figured that CTA button generates an attribute that's called cta_dest_link and from there you can read the absolute URL.

 

However, couldn't manage to find a solution using HUBL

 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Get page/blog post id from CTA button

Hey, @MKukanjac 👋 Thanks for the interesting question. Let's see if we can get the conversation going — @Kevin-C @FabianRichter @Anton have you spent any time digging around in CTAs? Thank you for taking a look! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes