Reputation: 119
I'm trying to add a tracking pixel in the wordpress single.php.
I found the tracking pixel code here: https://stackoverflow.com/a/18852257/1848279
and I wrote the logic, but I don't know how to include it in the theme so I can have a url with the image which to add in the single.php file.
The tracking pixel I'm trying to implement should expose a url like the following: https://www.example.com/pixel.gif
I tried other options but I'm using wp super cache which creates fully static html pages and serves them from nginx which blocks the tracking code from running.
Upvotes: 1
Views: 641
Reputation: 1546
I've seen analytics tools use javascript and fallback to pixels when javascript is not enabled. You need to create an image tag that point to a pixel file this could be a php or a location mapped to the php file. If it's going to be a pixel image then you should make sure that the image source has a randomness in it's url e.g. image.jpg?t=123123123 where it's current timestamp + random number.
Upvotes: 1