Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function getContentStatusLabel(status_id) {
- switch(status_id){
- case '121':
- return 'Open';
- case '125':
- return 'Closed';
- case '124':
- return 'Closed with follow up';
- default:
- return status_id;
- }
- }
- function getTopicLabel(topic_id) {
- switch(topic_id){
- case '92':
- return 'Arts and culture';
- case '95':
- return 'Communities';
- case '96':
- return 'Planning and regeneration';
- case '99':
- return 'Economy';
- case '100':
- return 'Skills and education';
- case '101':
- return 'Environment';
- case '103':
- return 'Health';
- case '105':
- return 'Housing';
- case '108':
- return 'Police';
- case '109':
- return 'Fire';
- case '110':
- return 'Transport';
- case '113':
- return 'Recovery from COVID-19';
- default:
- return topic_id;
- }
- }
- var params = new URLSearchParams(window.location.search);
- if (params && params.size !==0) {
- var customSearchData = {
- 's' : '',
- 'field_content_status' : [],
- 'field_topic' : [],
- 'type' : [],
- 'dates' : []
- };
- var keys = Array.from(params.keys());
- keys.forEach(function(key){
- var value = params.get(key);
- if (key == 's') {
- customSearchData['s'] = value;
- }
- else if (key.indexOf('field_content_status') !== -1) {
- customSearchData['field_content_status'].push(getContentStatusLabel(value));
- }
- else if (key.indexOf('field_topic') !== -1) {
- customSearchData['field_topic'].push(getTopicLabel(value));
- }
- else if (key.indexOf('type') !== -1) {
- if (value == 'forum') {
- value = 'discussion';
- }
- customSearchData['type'].push(value);
- }
- else if (key.indexOf('created') !== -1 && value != '') {
- customSearchData['dates'].push(value);
- }
- });
- window.dataLayer.push({
- event: 'talk_london_search_data',
- talk_london_search_data: customSearchData['s'],
- field_content_status: customSearchData['field_content_status'],
- field_topic: customSearchData['field_topic'],
- type: customSearchData['type'],
- dates: customSearchData['dates']
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement