Coding

How to Fire a Pixel on Click?

There are so many ways available to fire a pixel. We can directly use the pixel in the click URL field or any href link, but that won’t be compatible for all pixels. Few pixels will get error if it is appended with any click URL.

What is the best method to fire a Tag?

Using JavaScript to fire a pixel.

How to do?

If you want to fire when the banner or content is clicked ?. Add Onclick function to the Top/Outer DIV and implement OnClick Trigger to it.

Sample Code To Fire Pixel

<div id="Mycontent" onclick='firetag();'>
[%ThirdpartyCode%]
</div>

<script>
 function firetag() {
  var evp = document.createElement('img');
   evp.height = 1;
  evp.width = 1;
  evp.style.display = "none";
  evp.src = 'https://yourpixel.com';
  document.body.appendChild(evp);
 }
</script>

onclick=’firetag(); function triggers the pixel to fire.

Replace your pixel inplace of “https://yourpixel.com”

How to Check the pixel is Firing correctly?

  • Open Browser and preview the content.
  • Open Inspect Element and Move to network tab
  • Enter “yourpixel” in the search Tab
  • Click the content
  • https://yourpixel.com will appear in the search results
  • Click that URL and see the HTTP status. If the status code is green 200 under the header tab. Pixel is firing correctly.

Hope this article helps !!!!

*The information contained in this post is for general information purposes only. The information is provided by How to Fire a Pixel on Click? and while we endeavor to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the post for any purpose.

Enable Notifications OK No thanks