AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Conflicts in Google Analytics/AdWords Tracking
Rank: Member
Groups: Authorized User, Developers Joined: 11/13/2018(UTC) Posts: 23
Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Hello,
I am working on fixing problems with our Google Analytics and AdWords (Google Ads) tracking code, and I am running into some problems that I'd like assistance with. I need the Global Site Tag (aka gtag) present in the HEAD of every page on the site which refers to Analytics and AdWords for normal tracking. Then, I need the AdWords conversion event snippet to live in the HEAD on the order confirmation page (checkout-receipt) only, directly beneath the gtag.
I do have Page Tracking and E-Commerce Tracking enabled but I do not have the Google Analytics tacking widget in the store footer because the recommended placement for the code is in the HEAD, not in the footer.
I would love to have a way to be able to place the gtag code in the HEAD of every page easily, and then add the conversion event ONLY to the checkout-receipt page. Any ideas?
|
|
|
|
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'm not sure if this will work, but there is no reason why it should not. If you enter your code inside a HTML Snippet and insert that Snippet into the header (in our case "Store Header Compact") Widget Board, that should do the trick. We will be using Wisepop as a third-party add-on and are looking for the same thing, to add code to all pages, but in our case, the footer. I'm pretty sure support might come up with another way, but there should be no reason why this would not work. Just an idea, -Ray Edited by user Monday, February 15, 2021 12:23:43 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Authorized User, Developers Joined: 11/13/2018(UTC) Posts: 23
Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: ray22901031 I'm not sure if this will work, but there is no reason why it should not.
If you enter your code inside a HTML Snippet and insert that Snippet into the header (in our case "Store Header Compact") Widget Board, that should do the trick. We will be using Wisepop as a third-party add-on and are looking for the same thing, to add code to all pages, but in our case, the footer. I'm pretty sure support might come up with another way, but there should be no reason why this would not work.
Just an idea, -Ray Hi Ray, thanks for the input. This is how I currently have the gtag script embedded in the site, but it is not truly in the HEAD of the page HTML. At the top-most placement via HTML snippet, the script still lives in the BODY. This presents a problem because the adwords conversion event script must occur beneath that, but in the HEAD. Unfortunately, with it as-is, the conversion script fires before the actual gtag and so it is useless.
|
|
|
|
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)
|
You are correct, I just tried it and it puts it in the body. What about entering the ID under the page tracking section of configuration, and inserting the 'Google Analytics' tracking widget to the store footer? I know it should be in the head as stated, but why is it not working in the footer? Edited by user Monday, February 15, 2021 2:19:32 PM(UTC)
| Reason: Not specified
|
|
|
|
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'm trying to remember the name of the file that loads outside of the admin, but for the life of me I can't recall it. I believe you can enter some code there that will load in the header. UPDATE: PS: the file is theme.config, and its under the theme's directory. This will load contents in the header section of your site, I just verified this. There is a script section, I am curious if you can load your code there? Edited by user Monday, February 15, 2021 2:28:24 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Authorized User, Developers Joined: 11/13/2018(UTC) Posts: 23
Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: ray22901031 I'm trying to remember the name of the file that loads outside of the admin, but for the life of me I can't recall it. I believe you can enter some code there that will load in the header.
UPDATE: PS: the file is theme.config, and its under the theme's directory. This will load contents in the header section of your site, I just verified this. There is a script section, I am curious if you can load your code there? Unfortunately, I have not been able to locate that. I think there are several issues contributing to this problem: 1) The AbleCommerce store feature for Page Tracking in /Admin/Store/Tracking refers to Google Universal Analytics, which uses analytics.js in the footer as a widget. However, we have upgraded our Google Analytics tracking code to the Global Site Tag which uses gtag.js. As such, we cannot use the built-in store feature for tracking via Google Analytics because the widget is not updated to the latest version. 2) Given my above situation, I need to find a new and equally effective way of implementing the Global Site Tag into our website. Since I cannot use the store feature, I am exploring other ways to do this. Perhaps AbleCommerce can provide some information that would be useful? I need the gtag.js code to live in the header of every page on our website, and then I need the Google Conversion Event script to live on the order confirmation checkout-receipt page ONLY, directly after the gtag.js.
|
|
|
|
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 the gtag.js code to live in the header of every page on our website <<
Put that part in your theme.config file, just insert into the script area a line that points to the gtag.js file. It will be on every page in the header section. May need to reset IIS after you edit the theme.config.
>> I need the Google Conversion Event script to live on the order confirmation checkout-receipt page ONLY, directly after the gtag.js. <<
Make a custom footer just for the checkout-receipt page with your 2nd script.
This should work. -Ray
|
|
|
|
Rank: Member
Groups: Authorized User, Developers Joined: 11/13/2018(UTC) Posts: 23
Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: ray22901031 >> I need the gtag.js code to live in the header of every page on our website <<
Put that part in your theme.config file, just insert into the script area a line that points to the gtag.js file. It will be on every page in the header section. May need to reset IIS after you edit the theme.config.
>> I need the Google Conversion Event script to live on the order confirmation checkout-receipt page ONLY, directly after the gtag.js. <<
Make a custom footer just for the checkout-receipt page with your 2nd script.
This should work. -Ray Unfortunately I don't have permissions to access the theme.config file at this time. I was able to get the analytics Global Site Tag properly installed in the footer of every page on the site, as well as the Google Ads conversion script on the order confirmation page, directly beneath the Global Site Tag. Still isn't working properly. Here is the script: <!-- Global site tag (gtag.js) - Google Analytics --> <script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-2123927-2"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-xxx'); gtag('config', 'AW-xxx'); </script> </div> <div class="html-content-item"> <!-- Event snippet for Purchase conversion page --> <script> gtag('event', 'conversion', { 'send_to': 'AW-xxx/E0R_CNCruO0BEKmDv_8D', 'value': 1.0, 'currency': 'USD', 'transaction_id': '' }); </script> I cannot get any reporting in Analytics for any ECommerce data. Not clear on why at this point. Enabling the page tracking feature in the store adds widget information for outdated tracking code, so that is not an option. Would love some assistance from Able on this!
|
|
|
|
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)
|
Hi,
The option to add content in the head section of the page from the admin UI is page-specific. If you edit a product, category, or webpage, you will see an HTML Head field. The content added in this field will always render in the page HEAD tag.
But to add content in the page HEAD section globally, we have no option other than editing the file. Ray has pointed out the correct solution. You have to edit the theme.config file.
|
|
|
|
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 replying to his question, but I wonder if you would entertain me in a "what if scenario"?
He seems to be using the "store header compact" for his menu options, and this of course seems to be on every single page.
Would it be possible for him to create a "HTML Snippet", that includes the path to his script, edit the "store header compact" Widget Board and insert the newly created "HTML Snippet"?
Would that not insert this information into every single page that uses "store header compact"?
I have not tried this myself as I would have to make too many changes to my site, but I'm just wondering if this might work for him?
Many thanks -Ray
|
|
|
|
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 he wants to add the content in the HTML page HEAD section instead of the BODY section.
Adding an HTML snippet in a board that is used on every page will surely adds the content on every page but in the page BODY tag/section. The Html Snippet, Widget, and Board content always render in HTML body 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)
|
Got it. Thanks A suggestion would be for the next version to be able to add contents to the theme.config from within the admin section, just an idea since he claims he doesn't have access to anything outside the admin area. Edited by user Monday, February 22, 2021 1:46:31 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Authorized User, Developers Joined: 11/13/2018(UTC) Posts: 23
Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: ray22901031 Got it.
Thanks
A suggestion would be for the next version to be able to add contents to the theme.config from within the admin section, just an idea since he claims he doesn't have access to anything outside the admin area. The most appropriate suggestion in my opinion is for AbleCommerce to update the Google Analytics widget to a) support the latest Google Site Tag, because if that was updated to the most recent, then it would be as simple as enabling it. Unfortunately, I just don't have access to the theme.config file at this time. I've been able to install the Global Site Tag in the footer of every page using a widget board. Then, I created a copy of that footer area just for the receipt page where I added my adwords conversion script. It is now recording conversions in some way, but I haven't been completely successful yet. I think we can close this post out!
|
|
|
|
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)
|
Besides having the ability to edit the theme config internally, like you do right now with the css files, let's take your suggestion and move it up a notch. Instead of hard coding the Google analysis code, let the admin have access to the code in the backend. This way in the event it ever gets modified or enhanced by Google, all you have to do is copy and paste the new code into a text box and that code becomes part of the drop in widget. Pretty much the same thing you do right now with the Google universal analysis input area. Just a future enhancement that can solve many problems. Just an idea, -Ray Edited by user Monday, February 22, 2021 1:26:42 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Developers
Joined: 11/7/2018(UTC) Posts: 303
Thanks: 21 times Was thanked: 5 time(s) in 5 post(s)
|
I created a partial view that includes various tracking scripts and called that view from the <head> section of the _Base.layout.cshtml and it renders like it did on the current Gold site. (This site is still in development in AC9) Inside the partial view, I put various tracking scripts, but I also have code in a .cs file in the App_Code folder which gets pieces of data, like the order total,etc. It probably properly should have been put in a controller, but this site changes things a lot and wants the changes done fast, so I didn't want to have to recompile the site to use the change. In the partial view, I have code to distinguish whether page is receipt page or not, similar to what AC has in the WebpageController if (requestPath.IndexOf("Checkout/Receipt", StringComparison.InvariantCultureIgnoreCase) >= 0 || requestPath.IndexOf("Members/MyOrder", StringComparison.InvariantCultureIgnoreCase) >= 0) { // used to be in W2M_othertrackingwidget order = AbleCommerce.Code.OrderHelper.GetOrderFromContext();
if (order != null && order.Items.Count > 0) { // TRY TO LIMIT REFRESHES FROM MESSING UP THE TRACKING DATA if (order.OrderDate.AddMinutes(20) > LocaleHelper.LocalNow) {
code for order tracking.....
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Conflicts in Google Analytics/AdWords Tracking
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