title: Run facebook pixel with rails and turbolinks
body: <p>The Facebook pixel's initialization code and PageView code is recommended to be placed inside the  section:
  <a href="https://developers.facebook.com/docs/facebook-pixel/using-the-pixel#get" rel="nofollow noreferrer">https://developers.facebook.com/docs/facebook-pixel/using-the-pixel#get</a></p>
  
  <p>The problem is that the head of the webpage is never reloaded with Rails turbolinks. Pixel does send a pageView event to Facebook on pushState/popState, but with the wrong URL - the URL from the initial loading of the page. I'm assuming that pixel saves the initial location 
  (when the fbq('init') is called) and then reuses it for the PageView event.</p>
  
  <p>I tried to put the entire code segment in the body, but the result was "Facebook Pixel Error: Duplicate Pixel ID: XXXXXXXXXX" java script error. </p>
  
  <p>I tried to split the code and put the fbq('init', XXXXX) event in the head and then on page:change event to call fbq('track', 'PageView');
  But the problem is that this once again uses the initial URL.</p>
  
  <p>I also tried to set the window.fbq variable to undefined and call again init before PageView - all of this in the page:change callback.
  But then I got the "Facebook Pixel Warning: Multiple pixels with conflicting versions were detected on this page" and again the PageView was called with the wrong url.</p>
  
  <p>Has anyone ever made Facebook pixel work with turbolinks?</p>