Hi,I’m trying to implement Google Tag Manager (GTM) to generate structured data for search engine optimisation purposes.I want to add the code into the view.php for individual records so that when Google looks at them it picks up the structured data - which is only 5 strings of data.So far I’ve added the GTM code snippet into header.php and it’s appearing in the view.php when I view the page source. The next stage is to insert the json code into the view.php page but I’m unsure of where it needs to go?So…anyone know where to place the code?
ragingbullfrog wrote:
The next stage is to insert the json code into the view.php page but I’m unsure of where it needs to go?What json code? How do you use it? Can you post an example?
I can’t post the code without removing the script tags or a web address (had to replace the schema org web address), but this is what it looks like:{
“@context” : “schema web address”,
“@type” : “JobPosting”,
“title” : “{{WebJobTitle}}”,
“hiringOrganization” : “ARC Recruitment”,
“jobLocation” : {
“@type” : “Place”,
“address” : “{{WebLocation}}”
},
“datePosted” : “{{JobPostingDate}}”,
“baseSalary” : {
“@type” : “MonetaryAmount”,
“value” : “{{WebSalary}}”
},
“description” : “{{WebDescription}}”,
“employmentType” : “Full-time”
}The items in double curly brackets are variables in GTM that look like are functions that return HTML rendered on the page.
So you try to insert a script tag. You may try to put in in Page_Head, see the topic Server Events and Client Scripts in the help file.
OK, I worked this out and it may be useful to other users.I inserted my json code into xxxxxview.php which I can’t post in full here it seems.The sticking point was getting the variable picked up correctly, but after much trial and error I worked out that using the php echo piece of code as the dynamic variable worked.For example:“@type” : “JobPosting”,
“title” : "<?php echo $Vacancies->WebJobTitle->ViewValue ?>"This is just one part of the schema piece of code but the same principle works for all of the variables.This is an essential part of SEO for google web crawlers.