Follow these steps to link UTMs in a book issue generated from the web page on the /books/submit_issues URL:
- Add a utm module in the depends section of manifest.py , as follows:
'depends': ['base', 'website', 'utm'],
- Inherit utm.mixin in the book.issue model, as follows:
class LibraryBookIssues(models.Model):
_name = 'book.issue'
_inherit = ['utm.mixin']
book_id = fields.Many2one('library.book', required=True)
submitted_by = fields.Many2one('res.users')
issue_description = fields.Text()
- Add a campaign_id field in the tree view of the book_issue_ids field, as follows:
...
<group string="Book Issues">
<field name="book_issue_ids" nolabel="1">
<tree name="Book isuues">
<field name="create_date"/>
<field name="submitted_by"/>
<field name="issue_description"/>
<field name="campaign_id"/>
</tree>
</field>
</group>
...
Update the module to apply the changes. To test the UTM, you need to perform the following steps:
- In Odoo, UTM is processed based on cookies, and some browsers do not support cookies in the localhost, so if you are testing it with the localhost, access the instance with http://127.0.0.1:8069.
- By default, UTM tracking is blocked for salespeople. Consequently, to test the UTM feature, you need to log in with a portal user.
- Now, open the URL like this http://127.0.0.1:8069/books/submit_issues?utm_campaign=sale.
- Submit the book issue and check the book issue in the backend. This will display the campaign in the book's form view.