Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this article, we explained how you could check the deployment conditions on your website. We also explained how you can debug your script if your survey did not show as you had expected. In the following article, we will elaborate more on the deployment conditions and the reasons why these conditions can show a false value in your console.

Step 1: Deployment Targeting

Go to ‘Data collection’ > ‘Deployments’. Click on the pencil button of the deployment you want to edit. Drag the form you want to use to the centre and go to ‘Targeting’.

Step 2: Developer tools

Open the developer tools on your website, by clicking on the icon with three dots, in the top right corner, then, ‘More tools’ > ‘Developer tools’.

Step 3: Console tab

Go to the console tab, and type the following in the command line: document.cookie='LOG=true'. Refresh your page. You will see a page with ‘P>’ on each line.

Step 4: True/False values

If you have all toggles switched off in your deployment, except for ‘Append div to body of the page if not found’, you should only see ‘true’-values in the console of the development tools. You should also see ‘triggered!’ on the last line of your console. Remember, if you have recently made changes to your form, your previous version is still saved in your cache and cookies. See this article for more information.

If you want to switch on one of the toggles in the deployment, your console could show a false value for that condition.

Example 1

Say, you only want to show your form to 10% of your users. Switch on the toggle ‘Show only to a percentage of users’, and enter the value 10 as your percentage. Save the deployment by clicking on the green save button in the top right corner. Now, go back to the developer tools on your website. Since you have changed the deployment, you first need to delete your cookies. See this article on how to do this.

Once your cookies are deleted, go back to the ‘Console’ tab, and click on refresh. You will see a line with ‘passive condition set’ and a random number. If this random number is smaller than your percentage, it will return the value true. If this random number is larger than your percentage, it will return the value false. You will only see this line the first time you refresh the page. In this case, 79.5 is the random number, which is larger than 10, so it will return a false value. If all is done well, and you got a false value, you should not see ‘triggered!’ on the last line anymore, instead, you should see ‘not all OK…’ on the second to last line.

Testing and triggering surveys with a low ‘Show only to a percentage of users’ rate can be time-consuming. To manually trigger the survey you can edit the cookie values of the following cookies:

Pastease.[trigger_type].activated.XXX

Pastease.[trigger_type].chance.XXX

You can set the value of Pastease.[trigger_type].chance.XXXXX to “chance01.0” (or anything below the value used at ‘Show only to a percentage of users’). This is done by double-clicking on this cookie, in the Application tab. In our example, the random number was 79.5, which gave us a false value. If you change this number to 1.0 we will get a true value, since 1.0 is smaller than our percentage, 10. You can delete Pastease.[trigger_type].activated.XXX. 


If you now reload the page, this rule should be evaluated as true.

Example 2

It is also possible to add a condition based on a URL. In your deployment, switch on the toggle for ‘Show based on URL conditions’. Add two URLs by clicking on ‘(+) AND’: 

Both of these URLs should be correct according to our condition. This, however, is not possible. In your console tab, you will see a false value for location:

In order to use these two URLs, you will need to use the ‘(+) OR’ button, instead of  ‘(+) AND’: 

You should now see a true value, if you are indeed on one of the specified URLs, for location in your console:

Example 3

Let’s say you only want to show your form on a specific date. Turn this toggle on, and set your condition. In this example, we will use: 

If you go back to your console, you will see a false value for ‘Date’, if your condition is false, and a true-value if it is indeed before 14/08/2020. In this case, our condition is false:


You can also set several conditions for your deployment.


Easy html macro
theme{"label":"solarized_dark","value":"solarized_dark"}
contentByMode{"html":"<div id=\"surveyContent\"></div>","javascript":"var confluenceData = {};\nvar pageId;\nvar pageTitle;\n\ntry {\n confluenceData = JSON.parse(parent.window.name);\n var pageId = confluenceData.options.productContext['page.id'];\n var pageTitle = confluenceData.options.productContext['page.title'];\n} catch(e) {}\n\nvar src = 'https://collect.mopinion.com/assets/surveys/2.0/js/survey.min.js';\n\nvar vars = {\n key:'211a4fdb96626776846147095cc335b448e20458', \n domain:'app.mopinion.com', \n divName:'surveyContent', \n button:false, \n use_collect:false, \n useQuerySelectorAll:false\n};\n\nvar s = document.createElement('script');\ns.async = 'async';\ns.id = 'mopinionFeedbackScript';\ns.src = src;\ns.onload = s.onreadystatechange = function() {\n if (!s.readyState || s.readyState === 'loaded' || s.readyState === 'complete') {\n try {\n srv.loadSurvey(vars);\n } catch (e) {}\n }\n}\ndocument.head.appendChild(s);","css":""}