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. Commented Oct 10, 2018 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. Commented Oct 10, 2018 at 12:59
  • Maybe document.write('<img ....? Commented Oct 10, 2018 at 13:08

2 Answers 2


I solved this with the following:

const img = new Image();
img.src = `https://dc.ads.linkedin.com/collect/?pid=${linkedinPixelId}&conversionId=${linkedinEvent}&fmt=gif`

Here's a link to the LinkedIn documentation which wasn't obvious to find:



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

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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