Translations of this page:
 

pageHead()

void pageHead(string Content)

The pageHead() function writes content to the head (<head>) of the HTML output. This can be used, for example, on the first page of the questionnaire Open Graph Markup can be deposited to control the preview in Facebook.

  • Content
    The XML/HTML content to be added to the questionnaire page header.

Warning: Faulty XML/HTML code can cause the questionnaire page to be displayed incorrectly or not at all.

Note: If you want to add the same content to all pages of the questionnaire, you can also write it directly into the HTML template of the questionnaire layout.

Note: Preferably, use the library() function to load JavaScript libraries.

Customize Facebook Preview

If you want to define with which short text and image (thumbnail) the questionnaire is displayed in a Facebook post, you would place the following PHP code for this on the first page of the questionnaire:

pageHead('
  <meta property="og:url" content="https://www.soscisurvey.de/MEIN-PROJEKT/" />
  <meta property="og:image" content="https://www.soscisurvey.de/MEIN-PROJEKT/fb-image.jpg" />
  <meta property="og:title" content="Fragebogen zum Mediennutzungsverhalten" />
  <meta property="og:description" content="Media usage behavior is incredibly varied and individual. Take part in this incredibly exciting questionnaire!" />
');

If this does not work, it can have several causes:

  • Facebook has already called the link once before and has the old version (without image) in the cache.
  • The questionnaire was not publically accessible when Facebook first pulled up the link.
  • The code is not on the first page of the questionnaire or another questionnaire is defined as default under Compose Questionnaire.
  • There is an error in the URL of the image.

The easiest way to fix these problems is with a tool from Facebook, the Sharing Debugger. There you enter the link to the questionnaire and then click on “Troubleshooting”. If an outdated version is displayed, you can tell Facebook to rescan the page by clicking “Rescan”.

A quick description of the data:

  • <meta property=“og:url” content=“[URL]” />
    According to the specification, the questionnaire URL should be explicitly specified again.
  • <meta property=“og:title” content=“[Titel]” />
    The [title] to be displayed in the post.
  • <meta property=“og:image” content=“[URL]” />
    The [URL] of the image to be displayed.
  • <meta property=“og:description” content=“[Info]” />
    A description with max. 200 characters, which should be displayed in the posting.
  • <meta property=“og:type” content=“[Typ]” />
    The [type] of the offer (default is website) is relevant if you want, for example, the display for videos or news articles … but false information here can lead to blocking on Facebook. Possible types are described in the The Open Graph protocol.
  • <meta property=“fb:app_id” content=“[ID]” />
    A Facebook App ID if you want to use Facebook Insights. You can get the ID in the developer area of Facebook.
en/create/functions/pagehead.txt · Last modified: 27.05.2021 14:30 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki