Rank: Advanced Member
Groups: Authorized User, Developers Joined: 2/17/2019(UTC) Posts: 909
Thanks: 3 times Was thanked: 15 time(s) in 15 post(s)
|
I need to add a script to the header of every single page, what is the best way to do this? I got a funny feeling I'm gonna have to edit the _HtmlHead.cshtml file. Thanks Edited by user Tuesday, July 26, 2022 8:25:13 PM(UTC)
| Reason: Wrong File Name
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
You can do this by creating an HTML Snippet from the admin website menu. You have to drag and drop this snippet in header just like widgets. To make this available for all available pages, you need to make sure that this is added in all page templates where different headers widget boards are used. In the sample install there are two Headers: in Content Pages template and Checkout Pages template.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 2/17/2019(UTC) Posts: 909
Thanks: 3 times Was thanked: 15 time(s) in 15 post(s)
|
Thank you for your reply, but it's not working for me. The output must be between the <HEAD> tags, not the body. Google Tag Manager now consist of two parts, one for the body, and one specifically for the head section. Any other advice? Thanks, Note: obviously if I manually inserted into the _HtmlHead.cshtml it will work, the same probably holds true if I were to manually inserted in menu section, but I'm trying to avoid doing this manually. Edited by user Wednesday, July 27, 2022 7:58:05 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
Oh ok!
Then you have to the edit Base layout file in /Views/Shared folder. You can also create a partial view and call it in Head tag just like we are doing it with _HTMLHead.cshtml.
Hope this helps!
|
|
|
|
Rank: Advanced Member
Groups: Admin, Developers, Registered, HelpDesk, Authorized User Joined: 10/5/2018(UTC) Posts: 704
Thanks: 5 times Was thanked: 113 time(s) in 112 post(s)
|
I think you can achieve the requirement without making changes in the file.
But if you want to keep the default files unchanged, you can add a .js file in the Themes folder and add the entry in Theme.config in <scripts> tag.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 2/17/2019(UTC) Posts: 909
Thanks: 3 times Was thanked: 15 time(s) in 15 post(s)
|
Yikes, this is what I'm trying to avoid.
Maybe for a future update on a new version is having under settings a universal header section that affects all pages.
Thanks
|
|
|
|
Rank: Member
Groups: Registered, HelpDesk Joined: 9/29/2021(UTC) Posts: 17
|
We had this in OSC. It was called Header Tags SEO. It allowed you to enter keywords and metatags that you could assign to any page by simply checking the boxes.
|
|
|
|
Rank: Advanced Member
Groups: Authorized User, Developers Joined: 2/17/2019(UTC) Posts: 909
Thanks: 3 times Was thanked: 15 time(s) in 15 post(s)
|
Hello Lyonsperf, AbleCommerce has the same thing, but I'm not looking per page. It needs to be universal in one place across all pages.
Modifying the base layout was the easiest thing for us to do.
Important note: AbleCommerce is still using the old Google analytical format, I believe they are moving to the new format shortly if not already done in 9.0.6, we are still at 9.0.5. However, this will become useless down the road, especially if you're integrating tag manager.
Tag manager now can receive Google analytic information, you do not need a separate Google analytic script. However, in order for tag manager to work correctly there are two parts, one for the header, and one for the body, and it is highly recommended by Google that these be at the top of these tags.
So, it might be a good idea under settings in a future version, to have a tag manager header entry and a tag manager body entry.
Thanks
|
|
|
|
Rank: Member
Groups: HelpDesk
Joined: 11/15/2021(UTC) Posts: 10
|
The addon I was refering to in osc was universal . In the admin you would click on Header Tags SEO and from there you were able to make changes sitewide to any page.
Unfortunately, it seems that the new owners of osc have chosen to remove all the free addons and any support for their older versions and are focusing on the new one they developed. 20 years of free contributions gone.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close