0 votes
in SoSci Survey (English) by s139455 (190 points)

Hi,

Is it possible to "inject" JavaScript code to the HTML "head" section of the first and last page of a survey? Something like this:

<head>
// other code
// my JS snippet here
</head>

There is a need to track user engagement via Google Analytics and Facebook Pixel and typically with these tools you have to add a JavaScript snippet just before the closing "head" tag of your HTML.

Many thanks.

1 Answer

0 votes
by SoSci Survey (305k points)

You may either edit the Questionnaire Layout (for all pages in the questionnaire) or use pageHead() for single pages.

However, please note, that GDPR demands explicit agreement by the respondends before you are allowed to use tools like Giigle Analytics. Otherwise you risk severe punishment.

by s139455 (190 points)
I need to add something in the head section of the *last page* only. How do I do that given that PHP cannot be used on the last page?
by SoSci Survey (305k points)
On the last page it won't be possible that easily, sorry. You can, however, place all necessary JavaScript at the top of the content. That is no problem with JS.

Another option is to introduce another (new) page before the last page and use buttonHide() there. This will then work very similary to the last page.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...