Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#26 2017-11-22 10:12:36

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

I just assigned one of the private galleries to the new template, so that's the only page that's affected

Offline

#27 2017-11-22 10:19:41

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can some code be added to a gallery?

I see it. The page is throwing an error on line 3 of my_phplugins.php.

Did you use an existing phplugins file and add your code to the user area?


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#28 2017-11-22 10:34:29

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: Can some code be added to a gallery?

rod barbee wrote:

Google analytics can give you all sorts of data

And the new Data Studio lets you create some nice dashboards. I've created some interesting things using simply standard Google Analytics.

https://www.google.com/analytics/data-studio/gallery/


--Jim

Offline

#29 2017-11-22 11:17:14

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

Alrighty then!
I just got back and modified the code by removing the <?php and ?> plus added the echo line etc.
Works great!
Shows up on the report too.
I didn't edit the 'center' html, as I will look for an update script - plus I wanted to do the code myself and not cut 'n paste!
I'll take a gander at the recommended links...

Cheers all!

Offline

#30 2017-11-22 11:25:30

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

Yes the script was updated, so I edited the phpfile and now all albums use the 'tracking' template.
FYI, this is the new file content:

function ttg_scripts( $style, $path ) {   
echo'


function ttg_scripts( $style, $path ) {   
echo'

<script type="text/javascript">
var sc_project=7247521;
var sc_invisible=1;
var sc_security="8a4441b8";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hit counter"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/7247521/0/8a4441b8/1/" alt="hit
counter"></a></div></noscript>
';
    }    //END

Thanks again.

Offline

#31 2017-11-22 11:46:36

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can some code be added to a gallery?

it may be "working" for now, but the implementation is completely wrong.

You've got this bit twice:
function ttg_scripts( $style, $path ) {   
echo'

And the script is appearing in the wrong part of the page. Your code is appearing at the very top of the page's source code before even the doctype declaration (which should be the very first thing). I don't know how this will affect your page but I do know it's wrong.

How are you implementing this? Are you simply placing that code in a text editor and saving it as my_phplugins.php? If so that is very wrong.

As mentioned before, it needs to go in a phplugins file that already contains some absolutely necessary code that Ben and Matt have included. There's a section in those existing phplugins file where users can add their own functions. Your code MUST go in that area.
Matt and Ben have created the page hooks to place code in certain areas for a reason. What you're doing is completely bypassing this. In fact, I'm surprised the page's are even showing up.

Please re-read the instructions I posted earlier in this thread and use an existing phplugins file in which to add your code.
Also re-read the TTG documents on using phplugins: http://backlight.theturninggate.net/doc … _phplugins


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#32 2017-11-22 12:05:17

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

Hi Rod,

Thanks for checking it out.

Ok, I did follow the instructions:

"To use PHPlugins, duplicate the existing PHP file, /backlight/custom/phplugins/phplugins-pangolin-sample.php. Rename the file as you like, keeping the .php extension; for example “my-phplugins.php”."

Once I had replaced the hook that existed in there, with mine, I 'cleaned' up the file by deleting what I thought were comments, except for the
<?php and ?>

So all the other lines in the original file should stay? Including the ttg_user_load hook?

(phplugins-pangolin-sample.php was not changed.)

Also,  I did modify the copy in notepad++ locally, then ftp'd it over.

Yes, I have duplicated the first two lines - an honest mistake.

Edit:
I see in the sample php file that there is a line:
// SET USER FUNCTIONS BELOW
So, I should keep everything as it is and add my hook/script below this line?

Last edited by peter (2017-11-22 12:09:32)

Offline

#33 2017-11-22 12:12:28

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Can some code be added to a gallery?

peter wrote:

Edit:
I see in the sample php file that there is a line:
// SET USER FUNCTIONS BELOW
So, I should keep everything as it is and add my hook/script below this line?

Yes!


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#34 2017-11-22 14:03:46

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

So to clarify, this is bad:

function ttg_scripts( $style, $path ) {   
echo'

<script type="text/javascript">
var sc_project=7247521;
var sc_invisible=1;
var sc_security="8a4441b8";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hit counter"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/7247521/0/8a4441b8/1/" alt="hit
counter"></a></div></noscript>
';
    }    //END


and this is good:

<?php
/*
*    TTG Core Elements "PHPlugins" User Hooks v1.2 - initialization mainline
*
*    developed by john bishop images (http://johnbishopimages.com)
*    for Matthew Campagna of The Turning Gate (http://theturninggate.net)
*
*/

function ttg_user_load( $style, $path ) {
    $g_tsvrl = explode( ' ', $style );                          // Extract gallery type
    define ( 'G_STYLE', strtoupper($g_tsvrl[1]) );              // and set global for later
    $g_path = str_ireplace('\\','/',$path);                     // change \ to /
    $chunks = explode('/',$g_path);                             // and put into array
    define ( 'G_PATH', strtoupper($chunks[count($chunks)-2]) ); // gallery folder name is second to last
    //define ( 'TTG_SITE', '');                                   // set new site root for navigation, resources, etc.
    }

/*
*   
*    *************************************************************************************
*    *                                                                                   *
*    * Warning! When using echo or print special care must be qiven to using quotes.     *
*    *                                                                                   *
*    * Strings inside single quotes must contain only double quotes                      *
*    * or all single quotes must be escaped (ie \') or vice-versa                        *
*    *                                                                                   *
*    *************************************************************************************
*   
*    Fourteen user exits are defined in all web engines - all are optional
*        (i.e. ttg_user_load.php may be the only processing)
*       
*    Some web engines will have additional exits defined, specific to that gallery type
*       
*    Each is called with the same parameters:
*        %1    -    TTG gallery-style gallery-release
*                3 blank delimited values
*                - %1.1    -    'TTG'
*                - %1.2    -    string describing gallery type; no embedded blanks
*                - %1.3    -    a series of two to three period delimited integers
*                            describing gallery release level; x.y or x.y.z
*        %2    -    server filesystem file name and path of calling file
*       
*
*    Defined exits:
*
*        ttg_user_load           
*      - return value ignored
*      - called immediately after this file returns
*      - called before any output is produced
*      - all header and response variables are accessible
*      - cookie and session processing can be initialized
*      - globals to be used by later hook calls can be defined
*
*    ttg_head
*      - return value ignored
*      - called immediately before </head>
*      - encompasses nothing; use to insert content into the <head>
*
*    ttg_header_top
*      - if return=false, the contents of the normal Backlight header are skipped
*      - called immediately within the header section
*      - encompasses the full contents of the header section; can be used to replace those contents
*
*    ttg_header_bottom
*      - return value ignored
*      - called last in the header section
*      - encompasses nothing; use to insert content at the end of the header section
*
*    ttg_masthead_primary_top
*      - if return=false, normal Backlight masthead is skipped
*      - called immediately before the masthead element
*      - fully encompasses the masthead; can be used to replace it
*
*    ttg_masthead_primary_bottom
*      - return value ignored
*      - called immediately after the masthead
*      - encompasses nothing; use to insert content after the masthead
*
*    ttg_masthead_secondary_top
*      - if return=false, normal Backlight masthead is skipped
*      - called immediately before the masthead element
*      - fully encompasses the masthead; can be used to replace it
*
*    ttg_masthead_secondary_bottom
*      - return value ignored
*      - called immediately after the masthead
*      - encompasses nothing; use to insert content after the masthead
*
*    ttg_navigation
*      - if return=false, normal Backlight navigation is skipped
*      - navigation is separate from the header section, so not affected by the above ttg_header... hooks.
*      - encompasses the navigation <ul> element; can be used to replace it
*
*    ttg_main_top
*      - return value ignored
*      - called immediately within the main content column
*      - encompasses nothing; use to insert content at the very top of the main content column
*      - located outside the password protected area
*
*    ttg_main_bottom
*      - return value ignored
*      - called immediately before closing the main content column
*      - encompasses nothing; use to insert content at the very bottom of the main content column
*      - located outside the password protected area
*
*    ttg_footer_top
*      - if return=false, the contents of the normal Backlight footer are skipped
*      - called immediately within the footer section
*      - encompasses the full contents of the footer section; can be used to replace those contents
*
*    ttg_footer_bottom
*      - return value ignored
*      - called last in the footer section
*      - encompasses nothing; use to insert content at the end of the footer section
*
*    ttg_pallet_top_title
*      - if return=false, the encompassed code is skipped
*      - wraps the site title in the top pallet
*      - use to replace the site title
*
*    ttg_toggle_T1
*      - if return=false, the encompassed code is skipped
*      - wraps the label element for "page__toggle__T1"
*      - use to replace the toggle button with one of your own making
*
*    ttg_toggle_T2
*      - if return=false, the encompassed code is skipped
*      - wraps the label element for "page__toggle__T2"
*      - use to replace the toggle button with one of your own making
*
*    ttg_social_top
*      - if return=false, normal content is skipped
*      - called immediately before social media icons in the top pallet
*      - encompasses the social media icons; can be used to replace them
*
*    ttg_social_bottom
*      - return value ignored
*      - called immediately after social media icons in the top pallet
*      - encompasses nothing; use to insert content following the social media icons
*
*    ttg_scripts
*      - return value ignored
*      - called immediately before </body>
*      - encompasses nothing; use to insert content at the very bottom of the page
*
*    ttg_copy_top
*      - if return=false, normal copy is skipped
*      - called immediately within the page copy area
*      - encompasses the page copy; can be used to replace it
*
*    ttg_copy_bottom
*      - return value ignored
*      - called immediately before closing the page copy area
*      - encompasses nothing; use to insert content following the page copy
*
*    ttg_pallet01_top
*      - if return=false, pallet content is skipped
*      - called within pallet01, after masthead and navigation
*      - encompasses the pallet01 content area
*
*    ttg_pallet01_bottom
*      - return value ignored
*      - called after the pallet01 content
*      - encompasses nothing; use to insert content at the end of pallet01
*
*    ttg_pallet02_top
*      - if return=false, pallet content is skipped
*      - called within pallet02, after masthead and navigation
*      - encompasses the pallet02 content area
*
*    ttg_pallet02_bottom
*      - return value ignored
*      - called after the pallet02 content
*      - encompasses nothing; use to insert content at the end of pallet02
*
*    ttg_albumset_top
*      - if return=false, normal copy is skipped
*      - called immediately within the media area
*      - encompasses the gallery grid / slideshow; can be used to replace it
*
*    ttg_albumset_bottom
*      - return value ignored
*      - called immediately before closing the media area
*      - encompasses nothing; use to insert content following the gallery grid / slideshow
*
*    ttg_album_top
*      - if return=false, the album content is skipped
*      - called immediately within the media area
*      - encompasses the album grid / slideshow; can be used to replace it
*
*    ttg_album_bottom
*      - return value ignored
*      - called immediately before closing the media area
*      - encompasses nothing; use to insert content following the album grid / slideshow
*
*    ttg_single_top
*      - if return=false, single image and content are skipped
*      - called immediately above the single image display
*      - encompasses the single image and related metadata; can be used to replace it
*      - available only on single-image HTML pages for applicable album templates
*
*    ttg_single_bottom
*      - return value ignored
*      - called after the single image display
*      - encompasses nothing; use to insert content following the single image display
*      - available only on single-image HTML pages for applicable album templates
*
*/


// SET USER FUNCTIONS BELOW
// Some example functions are included below. Feel free to delete or modify unwanted functions.
// ****************************************************************************************************

function ttg_scripts( $style, $path ) {   
echo'

<script type="text/javascript">
var sc_project=7247521;
var sc_invisible=1;
var sc_security="8a4441b8";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hit counter"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/7247521/0/8a4441b8/1/" alt="hit
counter"></a></div></noscript>
';
    }    //END



/* DELETE THIS LINE
function _HOOK_( $style, $path ) {
    echo '

    ';
    return false;
} // END /**/




/* DELETE THIS LINE
function ttg_main_top( $style, $path ) {
    echo '<ul style="background-color:#FFF9C4;color:#000;margin:1.5rem 0;padding:24px 36px;">';
        if (PASSWORD_ENABLED) {
            echo '<li><strong>This gallery is private</strong>.</li>';
            if (LOGGED_IN) {
                echo '<li><small>The user is logged in</small>.</li>';
            } else {
                echo '<li><small>The user is logged out</small>.</li>';
            }
        } else {
            echo '<li><strong>This gallery is public</strong>.</li>';
        }
    echo '</ul>';
    return false;
} // END /**/




/* DELETE THIS LINE
function ttg_toggle_T1( $style, $path ) {
    // Below, the bare minimum markup required for functioning toggles;
    // fill in the LI element as you wish. Custom CSS may be necessary.
    echo '

    <label for="page__toggle__T1">
        <ul><li></li></ul>
    </label>

    ';
    return false;
} // END /**/




/* DELETE THIS LINE
function ttg_pallet_top_title( $style, $path ) {
    // Below, the default markup for the title. The LI wrapping element is mandatory;
    // replace the inner HTML as you see fit. Retain the "masthead_pallet_top" class and styling,
    // or assign a new class, with styling defined in custom CSS.
    // Take note, the top pallet height is a 48px fixed value.
    echo '

    <li class="masthead_pallet_top">
        <h1><a href="/">Your Site Title</a></h1>
    </li>

    ';
    return false;
} // END /**/




/* DELETE THIS LINE
function ttg_navigation( $style, $path ) {
    echo '
    <ul class="primary-menu menu mouseable">
        <li class="menu-item"><a href="/">Home</a></li>
        <li class="menu-item menu-item-has-children"><a href="/galleries">Galleries</a>
            <ul class="sub-menu">
                <li class="menu-item"><a href="">Sub-item 1</a></li>
                <li class="menu-item"><a href="">Sub-item 2</a></li>
                <li class="menu-item"><a href="">Sub-item 3</a></li>
                <li class="menu-item"><a href="">Sub-item 4</a></li>
                <li class="menu-item"><a href="">Sub-item 5</a></li>
                <li class="menu-item"><a href="">Sub-item 6</a></li>
                <li class="menu-item"><a href="">Sub-item 7</a></li>
                <li class="menu-item"><a href="">Sub-item 8</a></li>
            </ul>
        </li>
        <li class="menu-item"><a href="/blog">Blog</a></li>
        <li class="menu-item"><a href="/about">About</a></li>
        <li class="menu-item"><a href="/contact">Contact</a></li>
    </ul>
    ';
    return false;
} // END /**/




/* DELETE THIS LINE
// Adding new social media icons before ...
function ttg_social_top( $style, $path ) {
    echo '

    <li><a target="_blank" href="" class="social_media fa fa-google-plus"></a></li>

    ';
    return true;
} // END

// ... and after.
function ttg_social_bottom( $style, $path ) {
    echo '

    <li><a target="_blank" href="" class="social_media fa fa-pinterest"></a></li>
    <li><a target="_blank" href="" class="social_media fa fa-instagram"></a></li>

    ';
} // END /**/




/* DELETE THIS LINE
// Highlight menu item for current page
function ttg_scripts( $style, $path ) {
echo <<<SCRIPT
    <script>
    $("ul.menu a[href='" + window.location.pathname + "']")
        .parentsUntil('.menu', 'li')
        .addClass("current_page_item")
        ;
    </script>
SCRIPT;
    return false;
} // END /**/




// ****************************************************************************************************
// END USER FUNCTIONS

?>

Offline

#35 2017-11-22 14:26:16

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Can some code be added to a gallery?

Good in terms of the general file content, bad in terms of your code. Please use Rod's version of your code. (all single quotes in your code need to be escaped).


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#36 2017-11-22 15:00:21

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can some code be added to a gallery?

peter wrote:

Edit:
I see in the sample php file that there is a line:
// SET USER FUNCTIONS BELOW
So, I should keep everything as it is and add my hook/script below this line?

I seem to remember reading something about a user area someplace....maybe a couple of places..... wink


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#37 2017-11-22 15:06:45

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

So, you recommend I amend this script by adding a \ in front of every single quote?

Rod had modified my Statcounter original script. I have now replaced it with the latest version.

Actually, the version I am using is their 'Default' one. They have a list of guides for about 80 different programs, from Adobe Pagemill to Zine studio.

There seem to be certain rules about when the ' and " should be escaped. Plus some differing opinions.
I just want this to be over...

Offline

#38 2017-11-22 15:07:46

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

rod barbee wrote:
peter wrote:

Edit:
I see in the sample php file that there is a line:
// SET USER FUNCTIONS BELOW
So, I should keep everything as it is and add my hook/script below this line?

I seem to remember reading something about a user area someplace....maybe a couple of places..... wink

yeah yeah...
smile

Offline

#39 2017-11-22 15:29:27

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

That new script has a problem, so please ignore it - I will either revert to the original, with Rod's escape quote edit and append it into the file correctly or something else

Offline

#40 2017-11-22 21:50:38

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can some code be added to a gallery?

peter wrote:

So, you recommend I amend this script by adding a \ in front of every single quote?

......
There seem to be certain rules about when the ' and " should be escaped. Plus some differing opinions.
I just want this to be over...

The functions use echo to place code in the page.
echo is followed by two single quote marks and a semi colon.
Your code goes between the two quote marks.
If there are single quotes in your code, when the php sees the first it stops placing code and moves on. The problem is that what follows is likely invalid php ( because it’s still your code, intended for another purpose). When that happens, an error is thrown.

So you must escape any single quotes within the code you’re trying to add.

Read the top part of the phplugins file, Matt’s added a warning about this there.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#41 2017-11-23 02:25:06

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

FWIW, Google analytics doesn't show IP's for privacy reasons, but Statcounter does.

For us, this is the most useful info, as it gives us an idea of who is looking, and how often, fairly easily.

If someone is on a private gallery, then we know that, that IP belongs to a certain person.
When a potential customer contacts us, we can tag their IP with their name and then we can see if they do repeat visits.

In the long run, is there any benefit to us? Maybe not, but it's fun to see who's looking at what!

Offline

#42 2017-11-23 02:59:10

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Can some code be added to a gallery?

I can imagine some benefits to you. If you see the same person visiting over and over you know they're interested and they might be responsive to a personal email offering a discount or something.

But adding Google analytics might also have benefits. But it is one more damned thing to learn too....


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#43 2017-11-23 10:12:59

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Can some code be added to a gallery?

Another option is to output the code as-is, by closing the PHP before it and re-opening after, e.g.

function ttg_scripts( $style, $path ) {    
?>
<script type="text/javascript">
var sc_project=7247521; 
var sc_invisible=1; 
var sc_security="8a4441b8"; 
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" + scJsHost+ "statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hit counter"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/7247521/0/8a4441b8/1/" alt="hit
counter"></a></div></noscript>
<?php
    }    //END

Offline

#44 2017-11-23 10:18:32

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

Thanks Ben, good to know.

Last edited by peter (2017-11-23 11:14:14)

Offline

#45 2017-11-24 01:06:36

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: Can some code be added to a gallery?

peter wrote:

Google analytics doesn't show IP's for privacy reasons

Yes, it is a privacy matter and that's important. And it's also illegal in some countries.

You really don't need the IP.

Step back from the problem for a moment. You're not trying to track IP addresses. You're trying to track individual user behavior. This can be done in a way that protects privacy.

Tracking an IP address will fail to capture what you're assuming it will do. Every device used by a person will have a different IP, and that same device will get a different IP at a different location. Imagine this...

  1. Mary Jane is sitting at her home, then visits your site on hre mobile phone - that's one IP.

  2. Then she picks up her laptop because it has a bigger screen, then that's a second IP.

  3. Mary then goes to work with her laptop, that's a third IP.

  4. Mary is sitting at Starbucks and shows her friends some of the photos on her phone, that's a fourth IP.

  5. Mary goes home and uses her laptop again. This time it reconnects to her home router and due to DHCP it gets a different IP than it had the day before. That's a fifth IP.

Next, you're doing wedding photography so the scenario above doubles when Mary's new husband does the same. In this simple example, there will be up to TEN DIFFERENT IPs.

Wait, it gets worse. Mary also gave her log-in info to her mother and a few friends asking them to help her pick. Now you've got well over a dozen IPs to track down.

So you see, tracking the IP doesn't actually solve the problem. You're trying to track a user's behavior, not their IP. You're also making the actual problem more complicated. For example, which of the dozen or more IPs in the scenario I've just outlined are the individuals you are actually trying to track? That's going to take a lot of detective work, and to what end?


I'm certain you'll find that even after you get that code working, it doesn't work as well as you're expecting. For this you will just have to trust someone with experience that's been coding web sites.


Back to my recommendation to use Google Analytics. Note that Matt has already provided the Google Analytics code sample. You could have had that code up and running in less than and effort than this rabbit hole has taken.

It's good advice to take the short path to get something working, than to plow deep into unknown territories. Coding is a story of Br'er Rabbit and the tar-baby. Once you touch it, you'll get more and more stuck with it. Experienced coders have learned this lesson all too well.

My advice again, step back from the problem. The solution isn't StatsCounter because tracking IPs isn't giving you the result you're looking for. You may not be able to get exactly what you want without making your site very complex and difficult for your visitors (e.g. requiring them to always log into your site).

Google Analytics will get you close with much less effort. And you'll already have GA installed so the slight change avoids another tar-baby.



https://conversionxl.com/blog/universal … s-user-id/

https://developers.google.com/analytics … es-user-id

https://davidsimpson.me/2014/04/20/tuto … analytics/

https://www.lovesdata.com/blog/google-analytics-user-id

https://support.google.com/analytics/answer/3123662

https://support.google.com/analytics/answer/3123663


--Jim

Offline

#46 2017-11-24 03:29:19

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Can some code be added to a gallery?

Nice write up, Jim! I can only second your opinion. Happy Thanksgiving!


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#47 2017-11-24 04:55:21

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

Yes I am aware of the logistics of different IP's being used by the same person, be it at a work place or on a diff. device etc.
In the end, it's not something we're obsessed with and because our site/business is local, it's never that busy where we need to differentiate.

Here's why we have stats with IP 's:

Reason 1:

When we have just released a private album, we want to know if the couple have viewed it - my wife get's paranoid if she doesn't hear back from a couple after she's spent weeks editing a wedding and has finally released it to the client.

Since the user/password is only released to them, then we know if they have logged on. Having their IP at this time, just allows us to see how often they spend on the site etc.

If we see they have looked at the gallery, then we usually hear from them.

Reason 2:
We can see that we've had a visitor and what pages they went to and how long they spent at the site. If we tag that IP, we can see if they come back later.

The benefits are negligible really, but, it just gives us a glance at how people look at the site.
We have had meetings with people that we know, or strongly suspect first went on our site months prior, then visited again and booked a meeting.
That info, is just that. There is nothing to gain from it. It's just nice to know the history.
If a couple meet up for coffee, we have about a 90% booking rate. That's really the best stat. we have on how we do.

Can Analytics help us improve our SEO? probably yes. But we pay for ads and we get enough work (15-20 weddings/yr.) that covers that cost and gives us enough work. If it ain't broke...

Offline

#48 2017-11-24 08:07:32

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: Can some code be added to a gallery?

peter wrote:

Can Analytics help us improve our SEO?

I don't think you understand Google Analytics. It's not about SEO. It's for tracking user behavior and statistics about your site.


Everything you outlined above in Reason 1 and Reason 2 can be done in Google Analytics. In fact, that's what GA was designed to do.

It's also free, less complicated, will not slow your site, less maintenance, custom reports, and so on. I can't think of one negative for using GA, but I could list a few for trying to do this without it.


peter wrote:

If it ain't broke...

That's exactly why I'm recommending you stick with GA, and not go down this rabbithole that turns into a tar-baby.

I'll give up trying to convince you, but after some time I'm certain you'll find this statscounter wasn't worth the effort. It's making a simple problem more complicated. In the end, you'll spend more time going down this path and not get any more for the effort than if you used Google Analytics with the User ID as I've recommended.


--Jim

Offline

#49 2017-11-24 08:20:01

peter
Member
Registered: 2012-09-26
Posts: 271

Re: Can some code be added to a gallery?

I'm 100% sure you are correct Jim, but it's extra work that I don't need.

Statcounter is free (unless you want extra history) and we have used it for reasons 1 & 2, for 4 years.
No need to go down a rabbit hole, it's already on the site.

Plus reason 3 - my wife has no technical ability, but can read statcounter and tag an ip. If I have to set up Analytics, and show her how to access stuff, it's a rabbit hole that I don't want to go down.

That's what I meant by 'if it ain't broke.

Further down the road, I'll take a look at it, but for now, I'm ok.

Last edited by peter (2017-11-24 08:21:06)

Offline

#50 2017-11-24 12:13:20

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Can some code be added to a gallery?

peter wrote:

I'm 100% sure you are correct Jim, but it's extra work that I don't need.

You're missing Jim's point. He's trying to spare you from doing extra work that you don't need. You're already plummeting through the rabbit hole. Jim is suggesting you quit it, and just use Google Analytics as we have already implemented in Backlight. It's easy and it's done for you, and all of your effort to replace it is yielding you little or no benefit for your stated purpose.


Matt

The Turning Gate, http://theturninggate.net

Offline

Board footer

Powered by FluxBB