Grab title and description of a landing page

Anonymous
Not applicable
Hello,

I want to reuse title and description on the page and I would like it to be done automatically. I tried {html_title} but seems like it workd only with social buttons. Is there a token or something like that for these tags?
Tags (1)
9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator
@Ekaterina for a generic HTML page I would indeed assume you meant the <TITLE> and <META name=description> tags.  But in a Marketo context you have another title and description for every page, so it's not an "of course" situation.  Given that the HTML tags are, by definition, already in the page (so their values can be copied and reused in script) asking for clarification is not unreasonable.

In the particular case of Facebook OG tags you have the problem that FB's crawler does not (at the current time) run JavaScript.  Therefore if you wanted to maintain just one title/description statically, that title/description should be the OG tags section.  Then flip around your concept and copy the stored OG values to the standard tags.

var title = document.createElement('TITLE');
title.innerHTML=document.querySelector('META[property="og:title"]').getAttribute('content');

var description = document.createElement('META');
description.name = 'description';
description.setAttribute('content',document.querySelector('META[property="og:description"]').getAttribute('content');

document.head.appendChild(title);
document.head.appendChild(description);
Anonymous
Not applicable
I mean meta title and meta description of course.
The idea is to automate filling in og tags. Just put in tempate something like this and forget about it:
<meta property="og:title" content="{{Current Page Title}}" />
<meta property="og:description" content="{{Current Page Description}}" />
SanfordWhiteman
Level 10 - Community Moderator
@Ekaterina which of these Title/Descriptions did you mean?
SanfordWhiteman
Level 10 - Community Moderator
@Jason OK, I thought she meant the "outer" Title and Description in the Design Studio tree...
Anonymous
Not applicable
@Sanford I was under the impression that she meant the page title and meta description entered in the Edit Page Meta Tags dialog in the LP editor:
0EM50000000T6vz.png
SanfordWhiteman
Level 10 - Community Moderator
@Jason Is the user-entered Description echoed into an LP?  I don't think so and I'd hope not -- that's an information leak (imagine a desc "Use this for stupid clients").
Anonymous
Not applicable
You'll need to use JavaScript to get those values, and then write code to place them into your page elements. Honestly unless you are doing this on a massive scale, Josh's method is probably faster.
 
Anonymous
Not applicable
I considered this but actually it's the same as typing it manually.
Josh_Hill13
Level 10 - Champion Alumni
you can create a My Token like

{{my.Page Title}} and insert it into any template or page that will be used in a Program.