Grab title and description of a landing page | Adobe Experience League Community
Skip to main content
April 14, 2015
Question

Grab title and description of a landing page

  • April 14, 2015
  • 9 replies
  • 2557 views
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?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

9 replies

Josh_Hill13
Level 10
April 14, 2015
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.
April 14, 2015
I considered this but actually it's the same as typing it manually.
April 14, 2015
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.
 
SanfordWhiteman
Level 10
April 14, 2015
@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").
April 14, 2015
@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:
SanfordWhiteman
Level 10
April 14, 2015
@Jason OK, I thought she meant the "outer" Title and Description in the Design Studio tree...
SanfordWhiteman
Level 10
April 14, 2015
@Ekaterina which of these Title/Descriptions did you mean?
April 15, 2015
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
April 15, 2015
@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);