Google Ads conversion tracking | XM Community
Skip to main content

Hello, we are advertising our Qualtrics survey with Google Ads, and would like to feed back to Google the “conversions”, i.e. information who successfully completed the survey, so that the ad can be optimised and shown to people who are most likely to complete it.

 

Accoring to Google, the process has two stages:

  1. Installing a tag in the website header--which I have successfully completed through Look and Feel -> General -> Header, and Google seems happy with it. Here is the code from Google I used:

    copy the tag below and paste it between the head tags (<head></head>):

    <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-xxxxxxxxxxx"></script> <script> window.dataLayer = window.dataLayer || e]; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-xxxxxxxxxxx'); </script>
     
  2. Installing event snippet on the website which participants reach after completing the survey (e.g. the last question or the end of survey message):

    Install the event snippet on the conversion page. This is the page your customers reach on your website after they've completed a conversion – the "Thank you for your order" page, for example.

    Open the HTML for the conversion page.

    Copy the snippet below and paste it between the head tags (<head></head>) of the page, right after the Google tag.

    <!-- Event snippet for Submit form conversion page --> <script> gtag('event', 'conversion', { 'send_to': 'AW-xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxx-', 'value': 1.0, 'currency': 'GBP' }); </script>

 

How to complete step 2 above? I do not see any way to modify the <head></head> part for individual questions, even when editing them with html editor.

 

Thank you.

@kubato You can place the code in the header of the survey. This code is executed each time one of the survey pages is loaded. It checks if there is an element with ID “EndOfSurvey” which is only available when the actual end page is reached. The gtag part is not executed for questions before the end.

<script>
Qualtrics.SurveyEngine.addOnload(function() {
var checkEnd = setInterval(function() {
var endElement = document.getElementById("EndOfSurvey");
if (endElement) {
clearInterval(checkEnd);
// Insert your event snippet code here
gtag('event', 'conversion', {
'send_to': 'AW-xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxx-',
'value': 1.0,
'currency': 'GBP'
});
}
}, 100);
});
</script>

You find the header HTML editor here: 

Best
Christian


@chackbusch Thank you so much, it works!!


@chackbusch Would you know how to trigger the conversion for the final question (labelled {"ImportId":"QID3350"} when we export the data) instead of the EndOfSurvey message?

 

It turns out that we have multiple EndOfSurvey messages across the survey, and they all trigger the conversion. For example for participants who are excluded because they are outside certain geographic area or do not satisfy the inclusion criteria. But we want conversions to count only for those who complete the entire survey.

 

Thank you so much for your help!


@kubato Sure. I would suggest to remove the header code then and add this JavaScript to the relevant question: 

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
gtag('event', 'conversion', {
'send_to': 'AW-xxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxx-',
'value': 1.0,
'currency': 'GBP'
});
});

addOnPageSubmit is executed when the page is confirmed. So it will really only be executed if the customer reaches the end.

Best
Christian


Thank you so much @chackbusch, appreciated!


Leave a Reply