Skip to main content

Empty templates

Use case

Execute a custom JavaScript when an event occurs in the campaign, such as:

  • redirect to an external website or page based on the result of a personality test
  • request a 3rd-party URL with a pseudonymised userid after the identification form is submitted
  • trigger a tracking/analytics event without using a Tag Manager (the script must include a CMP integration to collect prior consent)

Variables

OPTIN-ID

Recommended

If you expect to track form submitted events only when a specific opt-in has been ticked (e.g. : newsletter subscription)

Create variable OPT-IN ID

Tags

Usage: only from campaign Tags

Use GTM event from campaign Tags

Event "First page"

  • Body
    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.pageNumber() == 1) {
    // Add below the script to be executed
    }
    });
    </script>

Event "Welcome screen"

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'intro') {
    // Add below the script to be executed
    }
    });
    </script>

Event "Questions screen”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'questionset') {
    // Add below the script to be executed
    }
    });
    </script>

Event "Form screen”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'identityset') {
    // Add below the script to be executed
    }
    });
    </script>

Event "Exit screen”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'exit') {
    // Add below the script to be executed
    }
    });
    </script>

Event "Already played screen”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName().startsWith("alreadyplayed")) {
    // Add below the script to be executed
    }
    });
    </script>

Event “Participate button”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'intro') {
    $('#jouer').click(function(){
    // Add below the script to be executed
    });
    }
    });
    </script>

Event “Question answered”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'questionset') {
    $('#suivant1, #next, .answerPic, [id^=check_choix]').click(function(){
    // Add below the script to be executed
    });
    }
    });
    </script>
  • Body (with question and answer values)

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'questionset') {
    let questionText = $("#question")[0].innerText;

    // Single Response (Answer buttons)
    $('[id^=check_choix]').click(function(){
    let questionAnswer = this.value;
    // Add below the script to be executed
    });
    // Multiple Response
    $('#next').click(function(){
    let questionAnswer = '';
    $("input[name=reponse]:checked").each(function() {
    questionAnswer = questionAnswer.concat($("label[for='"+this.id+"']").text(),",");
    });
    // Add below the script to be executed
    });
    // Swiper
    $('.answerPic').click(function(){
    let questionAnswer = $(this).find(".ic_response span").text();
    // Add below the script to be executed
    });
    }
    });
    </script>

Event "Form submitted”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.isFormSubmittedRightNow()) {
    // Add below the script to be executed
    }
    });
    </script>

Event "Form submitted with opt-in”

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.isFormSubmittedRightNow()) {
    if(tp.isOptin({tv:optin-id})) {
    // Add below the script to be executed
    }
    }
    });
    </script>
Set the expected opt-in ID

Set expected opt-in ID

Event "Personality test - Profiles of participants"

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getStepName() == 'exit') {
    if ('{group}' == 'Name of the profile A') {
    // Add below the script to be executed
    }
    }
    });
    </script>

Event "Instant Win - Participant won"

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.isWinner() == 1) {
    // Add below the script to be executed
    }
    });
    </script>

Event "Click on a button"

Add a custom event on an additional button

It can be a button available by default in the campaign

#buttonIdContext
s_dotationTop menu > Gift
s_detailsTop menu > Winner
s_reglementTop menu > Rules
s_contactTop menu > Contact
suivant1Questionnaire > Submit
suivant4Qualification Questionnaire > Submit
b_replayExit screen > Replay

or any button you added manually to the campaign.

  • Body

    <script type="text/javascript"> 
    $(function() {

    $('#buttonId').click(function(){
    // Add below the script to be executed
    });

    });
    </script>

Event "User is on mobile"

  • Body

    <script type="text/javascript"> 
    $(function() {

    var tp = _qlf_taggingplan;

    if (tp.getDevice() == 'mobile') {
    // Add below the script to be executed
    }
    });
    </script>