Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Adding Google Analytics to Mobile

I have used pockets to insert my Google Analytics code into my forum theme and it works great (unless it does something i don't know about)... but I'm having trouble with doing this for the mobile version.

I realize there are some add-ons out there that might be able to accomplish this, but unless one is approved by Vanilla Forums, I prefer to just paste my google analytics code into a header some place (of my mobile theme).

Can anyone help me insert GA tracking code into my mobile theme? I tried on the default.master.tpl, but got BONK.

Thanks!

Comments

  • you need to insert script within

    {literal}{/literal} tags

    or smarty will try to parse it.

    please search for 'Bonk' next time to know what to do, when that happens.

    grep is your friend.

  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    You can try my plugin http://vanillaforums.org/addon/advancedgoogleanalytics-plugin

    It embed the latest version of the google analytics code and works without editing any files (Tested only with >2.1). If you have vanilla 2.0.x edit the class file changing the line 'RequiredApplications' => array('Vanilla' => '2.1a1'), to 'RequiredApplications' => array('Vanilla' => '2.0'),.

    If you encounter any problem, just ask.

    There was an error rendering this rich post.

  • hgtonighthgtonight ∞ · New Moderator

    @Smitty said:
    I realize there are some add-ons out there that might be able to accomplish this, but unless one is approved by Vanilla Forums, I prefer to just paste my google analytics code into a header some place (of my mobile theme).

    Considering all the help you receive on this forum is not approved by Vanilla, I find this funny. :D

    That said, you might find it helpful to read the wiki on .tpl files and working with smarty.

    Welcome to the community!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    This is another good reason to turn the unapproved warning into a rating system. The warning can be in tiny letter somewhere not easy to find..... :)

  • @x00 said:
    you need to insert script within

    {literal}{/literal} tags

    or smarty will try to parse it.

    please search for 'Bonk' next time to know what to do, when that happens.

    I don't see literal tags on my default.master.tpl file. I use this theme: Embed-Friendlyversion 1.0

  • hgtonighthgtonight ∞ · New Moderator
    edited April 2013

    @Smitty Excerpt from the wiki article on smarty tags:

    You can prevent smarty from interpreting code using the {literal} tag.

    {literal}<script>
    function myFunction() {
      document.getElementById("myPar").innerHTML="Hello Dolly";
      document.getElementById("myDiv").innerHTML="How are you?";
    }</script>{/literal}
    

    This means you need to sandwich your google analytics javascript in between the {literal} and {/literal} tags.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight said:
    Smitty Excerpt from the wiki article on smarty tags:

    This means you need to sandwich your google analytics javascript in between the {literal} and {/literal} tags.

    Wow, much appreciated on the details. This may be a dumb question, but what is "smarty". If it wasn't already included, I doubt I downloaded it (if it's a plugin, etc). So curious if I need to? Your solution {literal} worked without me having to do anything else, though, so I assume all is well?

    Thanks again!

  • @vrijvlinder said:
    Smarty is a template engine for PHP.

    http://www.smarty.net/docsv2/en/what.is.smarty.tpl

    Great, thanks. I will read up on it. But given the fix above worked, and I do not have Smarty, I don't need Smarty, then right?

    Thanks again, everyone. This community is very helpful, and fast to reply!

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @Smitty said:
    But given the fix above worked, and I do not have Smarty, I don't need Smarty, then right?

    Well you already have Smarty , plus if the theme's master view is a tpl , then it uses Smarty which is in your library under vendors.

  • hgtonighthgtonight ∞ · New Moderator

    @Smitty said:
    Wow, much appreciated on the details. This may be a dumb question, but what is "smarty". If it wasn't already included, I doubt I downloaded it (if it's a plugin, etc). So curious if I need to? Your solution {literal} worked without me having to do anything else, though, so I assume all is well?

    Smarty is the template system that processes your theme's default.master.tpl file. If you look at your default.master.tpl file, you will see a few different words enclosed in curly braces. E.g. {asset name="content"}. Smarty takes these tags and fills them in with dynamic content. So your category view gets a list of discussions in a specific category, a discussion shows all the related comments, etc.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Thanks for all the help. Thanks even more for having such a helpful approach. So many support forums out there have helpful people, but they seem drained and annoyed helping those just learning the product. Refreshing!

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    @Smitty said:
    but they seem drained and annoyed helping those just learning the product. Refreshing!

    Give it time .... lol

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP

    @Smitty

    Just don't ask about Bonk!

Sign In or Register to comment.