Welcome to TalkGraphics.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    12

    Default Problem with Google adwords tags

    Hi there,

    I have been trying to add Google tracking codes to my website and there is a problem with the way Xara handles the sequence of <script> tags:

    Google needs a global tag on every page, such as -

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-43XXX2NPLR"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-43Q1XXXPLR'); // Analytics
    gtag('config', 'AW-1072XXX328'); // Adwords
    </script>

    That can be added into the Xara website either via the 'Web Analytics' tab or 'Website HTML Code (Head)'.
    All good so far. But for tracking action conversions i.e. where a customer then goes to a particular page, Google needs another tag on the particular landing page as well e.g.

    <!-- Event snippet for StartedKeySense conversion page -->
    <script>
    gtag('event', 'conversion', {'send_to': 'AW-1072XXX328/5G85CNTK-usCEICJuP8D'});
    </script>

    which must be immediately following the global tag.

    The problem is that the only way I can add the conversion tag is using 'Page HTML (Head)'. But when Xara uploads the website it puts this tag way, way down the sequence of code - nowhere near the global tag script. I cannot see any way to force it directly following the global tag. The end result is that Google doesn't recognise the tag (at all).

    The temporary 'fix' I have in place is to manually edit the pages after I publish (i.e. change the HTML source), then to remember to do it again every time there is an update.

    Surely there must be a better way.
    Any ideas anyone?

  2. #2
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,917

    Default Re: Problem with Google adwords tags

    Hi Warwick, I don't use Google Analytics but does the below work if pasted in the Page Head section i.e. just add both sets of code to the page head placeholder :

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-43XXX2NPLR"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-43Q1XXXPLR'); // Analytics
    gtag('config', 'AW-1072XXX328'); // Adwords
    </script>

    <!-- Event snippet for StartedKeySense conversion page -->
    <script>
    gtag('event', 'conversion', {'send_to': 'AW-1072XXX328/5G85CNTK-usCEICJuP8D'});
    </script>
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  3. #3
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,826

    Default Re: Problem with Google adwords tags

    I have the same suggestion as Egg.

    Never edit Xara code; therein lies Dragons!

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  4. #4
    Join Date
    Dec 2006
    Posts
    12

    Default Re: Problem with Google adwords tags

    Thanks for the responses. The solution I have come up with is to detect which page we are on and only trigger the conversion tag accordingly. This way the same code can be inserted in all site pages e.g.

    <!-- Global site tag (gtag.js) - Google Ads: 107xxx3328 -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=AW-107xxx3328"></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'AW-10xxx63328');

    if (window.location.pathname == '/test') {
    gtag('event', 'conversion', {'send_to': 'AW-10xxx63328/5G85CNTK-usCEICJuP8D'});
    console.log('On conversion page ' + window.location.pathname)
    } else {
    console.log('On some other page')
    }
    </script>

    Warwick

  5. #5
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,826

    Default Re: Problem with Google adwords tags

    @Warwick, as long as you are happy.
    You are introducing unnecessary code where you could just control it through additions in the page head.
    Code always needs testing.
    It also becomes wormy when you add or remove pages and variants.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •