1

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.

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

2 Answers 2

3

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:

https://www.linkedin.com/help/linkedin/answer/93957

1

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 that you have read and understand our privacy policy and code of conduct.

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