I am trying to send a LinkedIn Ads Insight Tag conversion on a specific page, using the page URL as the condition. The tag is firing as expected, but I see an error in the browser console saying:
Uncaught TypeError: window.lintrk is not a function
This error message seems to indicate that the conversion is being fired before the LinkedIn Insight Tag script has finished loading.
I have tried to change the conversion trigger from pageView to domReady or pageLoad, but the error message is showing up in all three scenarios.
Is there any way to tell Piwik PRO to wait for the LinkedIn script to be available before firing the conversion?
Also, I noticed that sometimes pageLoad is being fired before domReady in the debug window: is this to be expected?
One quick workaround to this problem that comes to my mind is to create custom script with Linkedin Ads Insight Tag code that would include conversion event line. That way you make sure that it loads tag and then fires conversion.
Make sure normal tag isn’t running at the same time on this page because it might send 2 conversions if normal page view tag loads before your custom solution.
Another option worth testing could be firing tags in specific order:
I also thought about including the main script with the conversion, but then as you mentioned I need to make sure that the main LinkedIn tag does not fire on all pages, which can quickly become a nightmare to maintain, as more and more conversion tags are added for different campaigns.
I am not sure that setting the priority is going to make any difference, because this feature doesn’t wait for the priority tags to finish before loading the non-priority tags, and the conversion is already being triggered after the main script.
I think I will try to add a custom HTML tag that waits 1 second before pushing a data layer event (let’s call it conversionLoad), and I will use that data layer event to fire all the page viewed-related conversions.