Open ak4zh opened 2 years ago
(Sorry that this answer comes late!)
How do you currently set the FACEBOOK_PIXEL_ID in your application configuration? Wouldn't a simple if
-then
-else
in your project settings module do the trick? e.g.
SITE_PIXELS = {
"one.example.com": "123",
"two.example.com": "456",
"three.example.com": "789",
}
FACEBOOK_PIXEL_ID = SITE_PIXELS.get(request.get_host())
Apparently, the trick here is to get access to the request
object. If that doesn't prove to be possible as some suggest you may set FACEBOOK_PIXEL_ID dynamically before the template gets processed, e.g. inside of a context processor you write yourself.
It may be worth to document such an approach in our documentation. Not sure if it makes sense to change the implementation of the template tag. If you think it is, I would suggest to try to find a generic approach for all template tags. (That said, PRs welcome!)
I have one django app hosted with multiple domains and sub-domains, and have different
FACEBOOK_PIXEL_ID
for all domains. For I uesrequest.get_host
to deside which css etc to serve for the current request.Is it possible to allow FACEBOOK_PIXEL_ID to be passed in the tag itself
{% facebook_pixel_head FACEBOOK_PIXEL_ID %}