Created
August 27, 2014 10:19
-
-
Save sbaechler/55f9053e658a3fe31008 to your computer and use it in GitHub Desktop.
Feincms Adform tracking extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Add the necessary tracking information to track each page with Adform. | |
Add ADFORM_PM to settings. Alternatively you could leave out the pm field and just | |
write it directly into the template. | |
<script type="text/javascript"> | |
{% if feincms_page and feincms_page.adform_id > 0 %} | |
var _adftrack = { | |
pm: {{ feincms_page.adform_pm }}, | |
id: {{ feincms_page.adform_id }} | |
}; | |
(function(){ | |
var s=document.createElement('script'); | |
s.type='text/javascript';s.async=true; | |
s.src='https://track.adform.net/serving/scripts/trackpoint/async/'; | |
var x = document.getElementsByTagName('script')[0]; | |
x.parentNode.insertBefore(s, x);})(); | |
</script> | |
<noscript> | |
<p style="margin:0;padding:0;border:0;"> | |
<img src="https://track.adform.net/Serving/TrackPoint/?pm={{ feincms_page.adform_pm }}&lid={{ feincms_page.adform_id }}" width="1" height="1" alt="" /> | |
</p> | |
</noscript> | |
{% endif %} | |
""" | |
from __future__ import absolute_import, unicode_literals | |
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
from django.conf import settings | |
from feincms import extensions | |
class Extension(extensions.Extension): | |
def handle_model(self): | |
self.model.add_to_class('adform_pm', models.PositiveIntegerField( | |
_('adform pm'), default=settings.ADFORM_PM,)) | |
self.model.add_to_class('adform_id', models.PositiveIntegerField( | |
_('adform id'), default=0)) | |
def handle_modeladmin(self, modeladmin): | |
modeladmin.add_extension_options(_('Adform'), { | |
'fields': ('adform_pm', 'adform_id'), | |
'classes': ('collapse',), | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment