How can I use LinkedIn pixel on a specific event in Angular 5 app? I got this crappy code from our SEO team:

<img height="1" width="1" style="display:none;" alt="" src="https://dc.ads.linkedin.com/collect/?pid=XXXXXX&conversionId=XXXXXX&fmt=gif" />

And it should run when a user completes registration. How can I fire it from code when the HTTP call is resolved. Facebook as way better documentation.

  • Why is that code crappy? It looks like standard pixel tracking to me. I don't know much about SPAs, but I expect you can insert HTML into the DOM with them whenever you need to. – Stephen Ostermiller Oct 10 at 12:52
  • Maybe I'm doing something wrong. Facebook has this fbq() function that I can use on event thats why I think its way easier to use from js code. My case looks like this: User is filling registration form hits submit - then if the http call was succesfull I need to send this pixel but adding it then doesn't work because the view is already changed. – Piotr Smyda Oct 10 at 12:59
  • Maybe document.write('<img ....? – Stephen Ostermiller Oct 10 at 13:08
up vote 1 down vote accepted

Thanks for all the input Stephen. I have finally got a solution. I've placed a tag like this <div [innerHtml]='linkedinPixel'> and am filling this variable with a proper link via service.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.