Hitting a facebook tracking pixel on the way out my site

时间:2015-05-12 22:37:29

标签: javascript jquery facebook

I want to use Facebook's pixel tracking to track exits from my site, not entrances to my site. I just want to hit it on the way out.

Their code looks like this:

let path = NSBundle.mainBundle().pathForResource("tutorial", ofType: "mov")
let url = NSURL.fileURLWithPath(path!)

moviePlayer = MPMoviePlayerController(contentURL: url)
let movieView = moviePlayer.view!

//this will be the height of your control
var heightValue: CGFloat = 400

//This will leave a marging of 50 on top
var top = NSLayoutConstraint(item: movieView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.GreaterThanOrEqual, toItem: videoViewBox, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 50 )
//This will be the height of the control
var height = NSLayoutConstraint(item: movieView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: heightValue )
//This will leave a marging of 10 at the end
var trailing = NSLayoutConstraint(item: movieView, attribute: NSLayoutAttribute.Trailing, relatedBy: NSLayoutRelation.Equal, toItem: videoViewBox, attribute: NSLayoutAttribute.Trailing, multiplier: 1, constant: 10)
//This will leave a marging of 10 at the start
var leading = NSLayoutConstraint(item: movieView, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: videoViewBox, attribute: NSLayoutAttribute.Leading, multiplier: 1, constant: 10)

movieView.setTranslatesAutoresizingMaskIntoConstraints(false)

NSLayoutConstraint.activateConstraints([top, height, trailing, leading])
    videoViewBox.addSubview(movieView)

moviePlayer.fullscreen = true
moviePlayer.controlStyle = MPMovieControlStyle.None

I want to do something like this:

<script>(function() {
  var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
    var fbds = document.createElement('script');
    fbds.async = true;
    fbds.src = '//connect.facebook.net/en_US/fbds.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(fbds, s);
    _fbq.loaded = true;
  }
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'MY_ID_NUMBER', {'value':'0.00','currency':'USD'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=MY_ID_NUMBER&amp;cd[value]=0.00&amp;cd[currency]=USD&amp;noscript=1" /></noscript>

The problem is that I don't know what their code is doing so i don't know how to do this. Where should I start? Can I just append their image that they have in the "noscript" tag?

1 个答案:

答案 0 :(得分:1)

It appears you could move <WebMethod()> _ Public Function CreateClient( _ ByVal strUserID As String, _ ByVal strVehicleID As String, _ ByVal strUnit As String, _ ByVal strHouse As String, _ ByVal strStreet As String, _ ByVal strCity As String, _ ByVal strContactName As String, _ ByVal strPhone As String, _ ByVal strComments As String) Dim strReturn As String = "14" Dim strLog As String = "" strLog = "CreateClient strUserID = " & strUserID & ", strVehicleID = " & strVehicleID & ", strUnit = " & strUnit & ", strHouse = " & strHouse & ", strStreet = " & strStreet & ", strCity = " & strCity strLog &= ", strContactName=" & strContactName & ", strPhone=" & strPhone & ", strComments=" & strComments Class1.WriteLogEntry(strLog, Class1.LOG_TYPE_DEBUG) Return strReturn End Function to inside your window._fbq.push event.

click