javascript - Page get redirected on Google Adwords Conversion Tracking - Stack Overflow

I've form where people submit data and the data is sent to the server using ajax. I've setup

I've form where people submit data and the data is sent to the server using ajax. I've setup this as a conversion in Google Adwords. Below is the code that I've used.

The problem is, when a user submits the form, after getting the response, its redirected back to URL that I've given. I don't want to redirect!!

(Data submitted is using Vue-resource since this project is in VueJS)

submit() {
  let self = this
  this.$validator.validateAll().then(success => {
    if (!success) {
      return;
    }
    document.getElementById("submitQuote").value = "Submitting...";
    this.$http.post(store.state.url+'api/submit_quote.php', {
        formData: store.state.formData
      })
      .then(response => {
        console.log(response.data)
        this.submitted = true
        self.reference_id = response.data
        goog_report_conversion('/') //report Google that a conversion has occured
      });
  });
}

Code given by Google

<!-- Google Code for Add to Cart Conversion Page
    In your html page, add the snippet and call goog_report_conversion
    when someone clicks on the chosen link or button. -->
    <script type="text/javascript">
     /* <![CDATA[ */
    goog_snippet_vars = function() {
      var w = window;
      w.google_conversion_id = 12345678;
      w.google_conversion_label = "abcDeFGHIJklmN0PQ";
      w.google_conversion_value = 13.00;
      w.google_conversion_currency = "USD";
      w.google_remarketing_only = false;
    }
    // DO NOT CHANGE THE CODE BELOW.
    goog_report_conversion = function(url) {
      goog_snippet_vars();
      window.google_conversion_format = "3";
      var opt = new Object();
      opt.onload_callback = function() {
      if (typeof(url) != 'undefined') {
        window.location = url;
      }
    }
    var conv_handler = window['google_trackConversion'];
    if (typeof(conv_handler) == 'function') {
      conv_handler(opt);
      }
        }
    /* ]]> */
    </script>
    <script type="text/javascript"
    src="//www.googleadservices/pagead/conversion_async.js">
    </script>                                                  

I've form where people submit data and the data is sent to the server using ajax. I've setup this as a conversion in Google Adwords. Below is the code that I've used.

The problem is, when a user submits the form, after getting the response, its redirected back to URL that I've given. I don't want to redirect!!

(Data submitted is using Vue-resource since this project is in VueJS)

submit() {
  let self = this
  this.$validator.validateAll().then(success => {
    if (!success) {
      return;
    }
    document.getElementById("submitQuote").value = "Submitting...";
    this.$http.post(store.state.url+'api/submit_quote.php', {
        formData: store.state.formData
      })
      .then(response => {
        console.log(response.data)
        this.submitted = true
        self.reference_id = response.data
        goog_report_conversion('https://www.example./') //report Google that a conversion has occured
      });
  });
}

Code given by Google

<!-- Google Code for Add to Cart Conversion Page
    In your html page, add the snippet and call goog_report_conversion
    when someone clicks on the chosen link or button. -->
    <script type="text/javascript">
     /* <![CDATA[ */
    goog_snippet_vars = function() {
      var w = window;
      w.google_conversion_id = 12345678;
      w.google_conversion_label = "abcDeFGHIJklmN0PQ";
      w.google_conversion_value = 13.00;
      w.google_conversion_currency = "USD";
      w.google_remarketing_only = false;
    }
    // DO NOT CHANGE THE CODE BELOW.
    goog_report_conversion = function(url) {
      goog_snippet_vars();
      window.google_conversion_format = "3";
      var opt = new Object();
      opt.onload_callback = function() {
      if (typeof(url) != 'undefined') {
        window.location = url;
      }
    }
    var conv_handler = window['google_trackConversion'];
    if (typeof(conv_handler) == 'function') {
      conv_handler(opt);
      }
        }
    /* ]]> */
    </script>
    <script type="text/javascript"
    src="//www.googleadservices./pagead/conversion_async.js">
    </script>                                                  
Share Improve this question edited Feb 23, 2017 at 7:11 m87 4,5113 gold badges18 silver badges31 bronze badges asked Feb 23, 2017 at 6:32 Gijo VargheseGijo Varghese 11.8k22 gold badges83 silver badges125 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Just don't provide a redirect URL to goog_report_conversion, i.e. call it without parameters.

The redirect is conditional:

if (typeof(url) != 'undefined') {
    window.location = url;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745087544a4610492.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信