[Résolu] How to insert Google analytics into layouts
This support ticket is created Il y a 7 années et 2 mois. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
I am trying to: insert Google analytics into Layouts.
I know that Layouts remove the <script> code, but i need it.
I tried to add this code to the content template, but it was also deleted.
What will be your advice?
Hello. Thank you for contacting the Toolset support.
You can add the Javascript (as described in the Google documentation: lien caché) in the custom JS section for Layouts at Toolset > Layouts CSS & JS.
[ Please note that you need to add your google analytics JS WITHOUT <stript> Tag - <stript> tag will be automatically appended]
However, this won't add the code in the head of your page as is recommended.
Then I inserted this shortcode into the footer of Layouts (parent layout)
Is this a bad example? Does such an approach affect speed?
One more thing.
I would like to ask whether it is possible for Layouts to work as Content template, so that I can insert raw HTML and mix it with shortcodes. Sometimes it is too difficult to deal with visual cells and their limitations...
Well - as per the standard we should add Google Analytics code to site's head (header) section. You can see the benefits of doing that with the following link:
=> lien caché
Regarding - the another question as I understand you would like to build the layout using PHP template. You can check the theme we offer "Toolset starter" theme to know how you can build your theme's PHP template with Layouts:
=> https://toolset.com/account/downloads/#toolset-themes
You should download the theme and check the source fiels.
Hello Minesh.
I use a Toolset starter theme in my project. And for the first time I try to work with Layouts. First of all, I want to say that I like the idea of complete freedom and control of the template from top to bottom. But I'm confused by some limitations. For example, the lack of the ability to insert code into the tag script. What can be easily done in a footer.php. Now I'm working on a landing page. And I want to say that it's faster for me to write the HTML code in the editor (sublime + emmet), than to create the design in Layouts. Maybe I'm doing something wrong?
I attach a screenshot of my layout. As you can see, I use a large number of visual cells, sometimes this leads to slow work when editing a layout. Perhaps it's better to use fewer visual cells, for example, each cell is a section that contains HTML and toolser shortcodes.
I just want to understand how I can use Layouts. I read all the documentation, I understand how it works, but I'm afraid that I will not be able to fight with its limitations or conflicts with other plugins (maybe) when the site is ready.
I also noticed that when you use Layouts, the page loads a little longer (1.3 before activating Layouts and 1.6 seconds after activation).
Finally, my main question. What will I lose if I refuse to use the Layouts in my workflow? After all, not so often client have to change the header, footer ..., it does not change often ....
What do you advise?
Well - We are working on Layouts and from now on Layouts will only be useful and have effect on your content area (body). Header and footer will not be part of Layouts and we allow that it should be controlled by your theme.
We are working on new Layouts Docs and it will take some time that's the reason I shared the idea to look at the "Toolset Starter" theme as the example so you will be able to know how this theme is built. Layout might affect the speed as well as it will be overriding the the_content part.
Finally, my main question. What will I lose if I refuse to use the Layouts in my workflow? After all, not so often client have to change the header, footer ..., it does not change often ...
What do you advise?
==> As I said, layouts will not use for header and footer but for your content area. So its up to your requirement that if you would like to go with Layouts or not. As you said you are more comfortable by editing theme's PHP templates you may leave layouts as you are able to build PHP theme templates with HTML on your own.
But if you would like to use layouts different features like different cells and other things then you should go with Layouts.
Thank you for the clarification. Layout might affect the speed as well as it will be overriding the the_content part.
Is this the same way that Content Templates work? If so, why Content Templates work a little faster?
Anyway, I think that It will be enough for me two plug-ins for building and displaying the content - Types + Views.
As you said you are more comfortable by editing theme's PHP templates you may leave layouts as you are able to build PHP theme templates with HTML on your own.
Thank you, but my knowledge is limited to httml and css. I'm just starting to learn php...
Is this the same way that Content Templates work? If so, why Content Templates work a little faster?
Anyway, I think that It will be enough for me two plug-ins for building and displaying the content - Types + Views.
=> Well - I mean to say it depends on the layout you build. For instance - if you build layout having 10 rows and you are using 25 different cells obviously it will be expensive. I also checked the layout screenshot you shared and I think the load time is expected for that layout as the layout screenshot you shared having around 20 rows and 30 cells.
Thank you, but my knowledge is limited to httml and css. I'm just starting to learn php...
==> Well - I asked you to use PHP tempalte because you confirm that you are enjoying to build PHP template as you find more easy to edit HTML and CSS there. So if that is not your cup of tea then I suggest you should go with GUI.